From patchwork Tue Dec 4 20:26:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 152852 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8503383ljp; Tue, 4 Dec 2018 12:29:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/WLWzk4YHoFrdgPREjFr6v6tdmGzTRgXRhU3o0zsQTI6VSoRhpXweK4kGt1gqbmOaWrUn1s X-Received: by 2002:a25:b086:: with SMTP id f6mr11032613ybj.116.1543955365655; Tue, 04 Dec 2018 12:29:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955365; cv=none; d=google.com; s=arc-20160816; b=pYwR3fi9c/pjsrc2gp1ar7779v1sKvl4eboE4fpzost5LgNFeJRgzilCgvtI6NzBmc 5Tg6UhMeOc3foYTwsx4HTvqqSIZgcgSY95wtoGLSmRW1KlD9D/pwo+wbGbxKfap4joO+ CwIrv4j7TScRCYG2Fk0mSmaWfIHkVhl2WPtxpo6DiM7AqD8pjer/DJ5cHMuDAdiyOzBf cnSNapQhoFiS/3uyfTzIgM9tL6h0yvU+nuM2KAVL/c6vSXdcbc0G9S47roWg2Ik/DUdN AIjo+t6lzuKwP4DnKz2rnlfZ9X1HkUB9EPEdLaUfp6qCmeGI7w3MOaD6wqS41RD1Izgj 9AOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=m/v0gxd+nXVhKHbcU6qc+bomDRYaYj//HlFhgLkNR5U=; b=VOyBEy3DjCmPYNtBkx0UOWDoE0HvsBxs87rUZzT0D8u6F8z+wa0arEiWRbtZT3lCxD MArX5fGwvbCm0BxgUVW9wkStVu8lW7PoaRvbwjPweW2Y96zcULKPHllixSWAyDp6LfPp 4FxD803uc/NMMP+1yf+aYAAGh7ORD6co1n0wjQJ4s8ljcy4jelx7P3TZrjFl3USxhV3z wWAWBL372D+v3hdYs7FR58tAr6x5yMk3ZiYO723lJQRuXA/qEVX0NlBV9q9g4UnJ32D4 8VvljV6nxspgED38ZEAfpPsLsRfd9PedEI9w1f6zAFMP3VBCoNw6/N2xtHIWeLX6pXlQ Ld6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v192si11530102ywa.235.2018.12.04.12.29.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 12:29:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gUHHu-00085o-9U; Tue, 04 Dec 2018 20:27:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gUHHs-00085Y-GJ for xen-devel@lists.xenproject.org; Tue, 04 Dec 2018 20:27:20 +0000 X-Inumbo-ID: ff51c996-f802-11e8-a585-df93f377db2e Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id ff51c996-f802-11e8-a585-df93f377db2e; Tue, 04 Dec 2018 20:27:19 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A5A4D15BE; Tue, 4 Dec 2018 12:27:18 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DD4F93F614; Tue, 4 Dec 2018 12:27:17 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Dec 2018 20:26:35 +0000 Message-Id: <20181204202651.8836-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181204202651.8836-1-julien.grall@arm.com> References: <20181204202651.8836-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 01/17] xen/arm: Introduce helpers to clear/flags flags in HCR_EL2 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A couple of places in the code will need to clear/set flags in HCR_EL2 for a given vCPU and then replicate into the hardware. Introduce helpers and replace open-coded version. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- The patch was previously sent separately and reviewed by Stefano. I haven't find a good place for those new helpers so stick to processor.h at the moment. This require to use macro rather than inline helpers given that processor.h is usually the root of all headers. --- xen/arch/arm/traps.c | 3 +-- xen/include/asm-arm/processor.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 88ffeeb480..c05a8ad25c 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -681,8 +681,7 @@ static void inject_vabt_exception(struct cpu_user_regs *regs) break; } - current->arch.hcr_el2 |= HCR_VA; - WRITE_SYSREG(current->arch.hcr_el2, HCR_EL2); + vcpu_hcr_set_flags(current, HCR_VA); } /* diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index 72ddc42778..cb781751a6 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -490,6 +490,24 @@ register_t get_default_hcr_flags(void); : : : "memory"); \ } while (0) +/* + * Clear/Set flags in HCR_EL2 for a given vCPU. It only supports the current + * vCPU for now. + */ +#define vcpu_hcr_clear_flags(v, flags) \ + do { \ + ASSERT((v) == current); \ + (v)->arch.hcr_el2 &= ~(flags); \ + WRITE_SYSREG((v)->arch.hcr_el2, HCR_EL2); \ + } while (0) + +#define vcpu_hcr_set_flags(v, flags) \ + do { \ + ASSERT((v) == current); \ + (v)->arch.hcr_el2 |= (flags); \ + WRITE_SYSREG((v)->arch.hcr_el2, HCR_EL2); \ + } while (0) + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_PROCESSOR_H */ /*