From patchwork Thu Jan 11 11:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 761817 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2337050wrz; Thu, 11 Jan 2024 03:09:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdCTcMFFhlqvVqbZ2seFFQc7hQtpv4BhC2kDeGKha+qvFYCSvJlKgze6piCnW59c4sxl/b X-Received: by 2002:a05:6808:330d:b0:3bd:537c:5fea with SMTP id ca13-20020a056808330d00b003bd537c5feamr826267oib.57.1704971373387; Thu, 11 Jan 2024 03:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704971373; cv=none; d=google.com; s=arc-20160816; b=A9F9KwTus2X3+nANXHSX1+z7hT7Omw5MkBvElTyezL8wXL2lq4WoJZ5CJmeXM32zH6 iXvHBNQyzGggkNW3USE+JBdHZ83p5+1vemR/wmrlg5Y9VVbLE6Wle2OwkbYExMXPYqaZ ZuNHTEmOj4CgerGO48Pwf3rSQ/A9YnPETwMrukP15LopaFTYBcEf2EaAVGSM39VU6PZi mtrYyRd9Pdy3xb/bQEX0zI6pNA0sy796NxvdKzElxmbbzRntNS0IYIbvy2MLixqIsi8Q FheRFllfFz0nPM3B0TCJwNsZeXmcB5D/GfJRRYrIRjszdTN6W7Tk3iG1pFuI806SPfw3 aqGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=JW8YIe50LT4PZiM8mDHqQtLIGx6RzO+LKTb370XSXVc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=LARW1bnG3kPQDQFyGoUHRjYSa/u9sHD5fmwEyYR8CPlPuq5JNRUMndStD9Yw4MOtY5 jpeWdYj3qp8vlba0kd7aKHMPvWVlWn7zNSpaKLu+OYz45AOry3f1xEeQ5Y/evl5hxD56 7fAxXRzVU9Xti576uknPRtEMfe2+1hThPXhNV7DRJYQ+PWPVJFjQcFOayq+4glcvPOvs /7L3NeTpyMZ9fj5WyoMv3aHFxeiyd30vT0BTzXRq5XOiM69iyEPAIZvPknxHn0Tcs8zI K7DIFs0kbb3UBQWZ6NZXrcIZ+opNsyl2RKT4ivOienM32b2bC0rd7SPBxekwc71hP7BC rB+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OhRz9XnM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bb41-20020a05622a1b2900b004298f46a4e4si697217qtb.736.2024.01.11.03.09.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2024 03:09:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OhRz9XnM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNssk-0001ha-HO; Thu, 11 Jan 2024 06:05:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNssB-0001Mt-BL for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:19 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNss9-0004Ro-28 for qemu-devel@nongnu.org; Thu, 11 Jan 2024 06:05:19 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-337874b8164so359078f8f.2 for ; Thu, 11 Jan 2024 03:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704971116; x=1705575916; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JW8YIe50LT4PZiM8mDHqQtLIGx6RzO+LKTb370XSXVc=; b=OhRz9XnMtL5LtnZ/EvexsRcx6g632WblfUwxHRXkDMdQ01bZSznU5dS3mjEKu1BmiZ xokdVl4cICVxSdtTq9IaGFL8wkU0UfZfjEkl2T0VcN+Rdq2B5rBIQAVObrBTFntChpak mjoUGcS4nUi6yF6Q34vJV2083YVITyDutytOg1v9iPbAtxJp7UwvKhoQgzjKHaVH4LeA /I75L9bWznEH8ugckVObt9aFOzFIoVtpbiOjM3fAEPw28NfTCmEyR8YvljVCQo5yBhqz rU/0BHaBMmzjJmgJC2uksCh96wAoyC9UeTpIocevA7CvciqAEq2gZkq3ciFRpl+buzn8 OYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704971116; x=1705575916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JW8YIe50LT4PZiM8mDHqQtLIGx6RzO+LKTb370XSXVc=; b=sNJXDPxJHF7MGN0Hh74BSlBTpV3KZDK8KCUcs6rfMhUFofPgpiQKZdFxPUbsGawARZ dXhBfxYb35RUz1u8HCadAP+vVnt6uqFsCX8MPfPRIi/byCyHhq+RD/g+Bng8NxtYKmQK C7JC5ftVCywBBydWqfImYOJnjrdgsIMEX/rMh+2DHpkvVUCmtkYx3FoH/gLzNNFlRgNs hDorDhPhpPnKNUZTo1Eca09x8dlaK5ZLfxRRSclCRlgMf6ZO/AQGGciG9GFh+OKzNHbS hnJ56sL1Vxjms3kHrWROOBZZrwvVUzYBN+3hZ2KaolgzUTSJoSPu1HG+ipmPStFWactF JWzw== X-Gm-Message-State: AOJu0YzyCRhw033As6K9d+3bEpMWxAKBfSC/y49N5Firyx6uomeVskd1 W2luM6kc5gZGIsd0uankMV9RLZVq60RA0yhWEVG5KcxhYQ0= X-Received: by 2002:adf:e812:0:b0:337:2e5d:4ac9 with SMTP id o18-20020adfe812000000b003372e5d4ac9mr534530wrm.81.1704971115813; Thu, 11 Jan 2024 03:05:15 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v30-20020adf8b5e000000b0033690139ea5sm951323wra.44.2024.01.11.03.05.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:05:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/41] target/arm: Set SPSR_EL1.M correctly when nested virt is enabled Date: Thu, 11 Jan 2024 11:04:45 +0000 Message-Id: <20240111110505.1563291-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240111110505.1563291-1-peter.maydell@linaro.org> References: <20240111110505.1563291-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org FEAT_NV requires that when HCR_EL2.{NV,NV1} == {1,0} and an exception is taken from EL1 to EL1 then the reported EL in SPSR_EL1.M should be EL2, not EL1. Implement this behaviour. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Miguel Luis --- target/arm/helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7c7f92c16de..e48b03ba1d0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11249,6 +11249,12 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) old_mode = pstate_read(env); aarch64_save_sp(env, arm_current_el(env)); env->elr_el[new_el] = env->pc; + + if (cur_el == 1 && new_el == 1 && + ((arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1)) == HCR_NV)) { + /* I_ZJRNN: report EL2 in the SPSR by setting M[3:2] to 0b10 */ + old_mode = deposit32(old_mode, 2, 2, 2); + } } else { old_mode = cpsr_read_for_spsr_elx(env); env->elr_el[new_el] = env->regs[15];