From patchwork Mon Jul 16 17:27:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142085 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677812ljj; Mon, 16 Jul 2018 10:29:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd+lcTcqj45fIpme81sybXLc4x6uXDwcnv5YKdto1LfNEqQwQzurPRUbnyvz5DTLmUkJgEl X-Received: by 2002:a24:65d5:: with SMTP id u204-v6mr12747468itb.8.1531762187363; Mon, 16 Jul 2018 10:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762187; cv=none; d=google.com; s=arc-20160816; b=TqL5DRix5YRt5zPW6N6iYefAqCnLKEQ4P8gn4HoMGqQq5FqzyrGpDRZl7ggzz3DlRX AzQ04GVW7mgubEOKTk+K8ORwdot1sWPNRokKw/xzxpHzGIscx+B5YDJHWtlJ39NcGQQi hWax83xOBNsk80xR7XGxX0Fg2EhYz///vj7pU3lgJhE4AtrPuWIheT+BZmAnX01r3X+a /0yI2giBX0BAJzZzi/kuryFCXpQ+3Xhp8MddVkQf9JHeVn6KlTFQYvZLeIxzFGxv6mzz DXhhbtQJEFM6aOydDPRjIpaMocEzypQ/smqcGCRLgdnlWdcgXn2OTKvq2CNIVYbPLP3J +4ZQ== 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 :arc-authentication-results; bh=BR7+ntI9F5am4IUPaBmhKUiuPhG4PNe8hz76fzEqA6I=; b=h3zvrOcUpLLwNEtKdlyDN5opWi03iFXco2ZaEV4Y3eCpjGnh0hc0vQqKZYzyZmRfhu WisFXbGOo7LFZ1mv4c2Ieg4KoylPOtfkAMup3PucqAeVmXsYp1ynPLVORbIlXOujMNFS HITfKu4wsdSiw5soffoRWrwb8N3TC+ru+iP8K+RfLUizboi7Dls5i7kE0+7oauTygHND b7Tr+nvxmPv9FbwyWoC1AA1jCrploWOGaavtvWFvlQu6hVwoNPOCwaN/cHraaRGfbE6c yAI6IPBzJ/oCSOtb8cAlFYSgCySPZ7HzWpr7mf7jZbDYaatzyB51vIV9UntN7gt169XP xSpw== 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 f23-v6si19678230ioh.21.2018.07.16.10.29.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:47 -0700 (PDT) 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 1ff7HQ-0006R8-Gm; Mon, 16 Jul 2018 17:27:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HP-0006Qx-Ij for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:23 +0000 X-Inumbo-ID: 85541e5e-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 85541e5e-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:32 +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 5764E15AD; Mon, 16 Jul 2018 10:27:22 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6ACFF3F5B1; Mon, 16 Jul 2018 10:27:21 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:00 +0100 Message-Id: <20180716172712.20294-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180716172712.20294-1-julien.grall@arm.com> References: <20180716172712.20294-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 03/15] 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, Julien Grall 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 --- 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 9ae64ae6fc..d1bf69b245 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 222a02dd99..7e695c2418 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -843,6 +843,24 @@ void abort_guest_exit_end(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 */ /*