From patchwork Sat Feb 8 12:58:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183230 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1949682ile; Sat, 8 Feb 2020 05:04:38 -0800 (PST) X-Google-Smtp-Source: APXvYqylDr8tKdXVOVDaS/+SmTkgWu6utKk33BL93Qj4g9knqqtaN2jcftMtdBMsY2O0mj5G/vk7 X-Received: by 2002:ac8:5448:: with SMTP id d8mr2683732qtq.205.1581167078101; Sat, 08 Feb 2020 05:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581167078; cv=none; d=google.com; s=arc-20160816; b=jveJ7KPDg3GTb3BTyVPHJraMtNlIhmIzcxN2KC+M8YIehfO5l6FPmaq6DxymofnWPg bI0Krg+eCvQmkYvN4swxZyUk4ZrOqVHwS29KYG02swGbFYHpZr0pchMMZxKUHKtHbbPF 9fOmIUzWbk0s3BlTGfRWyswogIdFDEmfCzwqTB172Dy7TJXSe7qa07yzOG0sr2CamJgb 1KFhB/cvZLhptTmfodJQecSUsLlF5hv8ga2B8fgCSCTWjVKc2qA8dRmwqGjCW7qf8Jj1 ftIgs5B7qQ8lkPabSxSUd7VE41cHpdpSHJp7dvsJfP3eww5TiabEkcW/DjS5steV8U4Z zE0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=wslv7CYEufFwFJCvr0YawYhKrjC9XNcJ2ZwEcRCjRWY=; b=pzqaXqCAUxISCulmIn6wnS/pmfQB7+ULiqGwhZtLiWSm9gAgufwzl6R3H/+xS45fmR itjAZMv4lCvrHqJFNQI4vW8q9HI06ws5jAyJWZAjTWWVD4Kr2coUBPyfM9wE51dKfxQW 5u+1DJHVWvPbrm7nKvgEtSt7OgJU2v7QFanHQbTdbqXoqOaDB94OOJVzkCuXd89JDEy9 Xag/wZXxkrZAZAxlguLoJelAfLfb09IROnyvHUkLqfRlLH1qBsYpshPcgyytN1JKIjvw Zpbf4g45DWQKrywzHijvmemztJO8jniYi2hQiX0+AGh8Ro2/9yP1V8oUIkJK7b4kNTne gcOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pDrjfa2N; 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 3si1519750qtg.196.2020.02.08.05.04.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Feb 2020 05:04:38 -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=pDrjfa2N; 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]:41126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0Pmn-0003lI-KQ for patch@linaro.org; Sat, 08 Feb 2020 08:04:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41449) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0Pgr-0000as-W0 for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0Pgq-0004s1-To for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:29 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54370) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0Pgq-0004ni-NT for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:28 -0500 Received: by mail-wm1-x341.google.com with SMTP id g1so5183231wmh.4 for ; Sat, 08 Feb 2020 04:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wslv7CYEufFwFJCvr0YawYhKrjC9XNcJ2ZwEcRCjRWY=; b=pDrjfa2N7354imQpFehVJRZrkGS7Ke2bk8VJBnXpuBMGsWBXiJSu0l6SbGH9VZED/v hHwMZAY8Oe9GqVEUOal6hvSgc7E/lHQ0wQkfC/eJhNU3mjsn+VU8CT49t7EiQvqXDOV4 pc7BfbpdZar3nwFiVn38fIfZLvNPZ8d/RFnoGLuu44+oDXN3u0eSGqrmP0KrkDDRt63W QSiykQFzqpqxFsWR6sBt8OFyeQqxT6pyE+19JISgJS7l7jwFJKR0vvEk3QMi/vMNk+xK Wefq3spBy10J+teZwFPNQvt5mJI02Mj6MX0qI96y4+rhfAMoXSSHd2f+esqRgxma+kRN 4YIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wslv7CYEufFwFJCvr0YawYhKrjC9XNcJ2ZwEcRCjRWY=; b=OPh1l6nXNHWNGfI4I9xHDvma6Yoq+GimHHJDC6/9jD5p1w8HUreJuLOMo4a3mO+lVB 8/ZC4rf9NCXI0Gt01cB6I4ki23B+tQ5E+MjdHmQ7RKL7TRqehC2+VJSP2rplRbxuI7Cu BaqbD43pGK7Bl2MYfR8OsxXuwBg8bzAAlkyuuiUaoOTgwWljVupI0iRt45cMF33H3zCC nC+8RV1KjRloHEIcliUGxDUVV27bu/4fXqXhKCnKQahCJDLYSgBDMrNJSU9LEmyUdl+C 9La14hDfgnO95BFG9+ZavIFfVafWhU6D4BaxC43Zzt+xkLD96iYniZzXsAB4cU8Sxnfr cNtg== X-Gm-Message-State: APjAAAXYckTSPaiihjr4u1cKHV0X6dYyR3fO1Kd8+RwIn4rF8Oiaw9Qw JnBjSfCAYev+XMPbRcGn1LsVN5/6jcd66A== X-Received: by 2002:a05:600c:2301:: with SMTP id 1mr4433546wmo.147.1581166707530; Sat, 08 Feb 2020 04:58:27 -0800 (PST) Received: from localhost.localdomain ([82.3.55.76]) by smtp.gmail.com with ESMTPSA id p5sm7490534wrt.79.2020.02.08.04.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 04:58:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 10/20] target/arm: Introduce aarch64_pstate_valid_mask Date: Sat, 8 Feb 2020 12:58:06 +0000 Message-Id: <20200208125816.14954-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200208125816.14954-1-richard.henderson@linaro.org> References: <20200208125816.14954-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use this along the exception return path, where we previously accepted any values. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 12 ++++++++++++ target/arm/helper-a64.c | 1 + 2 files changed, 13 insertions(+) -- 2.20.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index 0569c96fd9..034d98ad53 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1085,6 +1085,18 @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, return valid; } +static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) +{ + uint32_t valid; + + valid = PSTATE_M | PSTATE_DAIF | PSTATE_IL | PSTATE_SS | PSTATE_NZCV; + if (isar_feature_aa64_bti(id)) { + valid |= PSTATE_BTYPE; + } + + return valid; +} + /* * Parameters of a given virtual address, as extracted from the * translation control register (TCR) for a given regime. diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 0c9feba392..509ae93069 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1032,6 +1032,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) cur_el, new_el, env->regs[15]); } else { env->aarch64 = 1; + spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); pstate_write(env, spsr); if (!arm_singlestep_active(env)) { env->pstate &= ~PSTATE_SS;