From patchwork Mon Oct 8 18:33:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 148423 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3982040lji; Mon, 8 Oct 2018 11:36:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63nWUNfgWNuIxd1iepGcppbPtd4+yUw52wqJbdwBkCLFyaow4x6SruYgJ3tJ5fdVNc0zheB X-Received: by 2002:a6b:17c6:: with SMTP id 189-v6mr15624180iox.226.1539023774847; Mon, 08 Oct 2018 11:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023774; cv=none; d=google.com; s=arc-20160816; b=QXJXVCfGqxUpQm+L4UBGjxducChS/pwkFg51lZaXT9K0oYY0/oRkm2RvKPaX1BMgEk DCgDQUmKnGNmCjVlaTJkmH8AUQIiBrSuyj/I83IMGOUxuaMN7pTR1aIVmRacnrbzBuQC MlC4DWbKAouZRWtOjCeqGat0WAVVieEF/rH0vmx2j8FgNds7nSpQFeJZtU9scj6G4s2P PAiHBx2rMOkSi3JoTmrBJ5BvQk+jhOG2N/DqHk8w7pHJ+8E7amkmwXX+VC2Ih6/s1A8W xuOtEiCXSEGXAOzG9dS13YIjrI6bVTsfVpKtzMmokHjio73Tu3Rxdp7zHNuN8sby/Asu SDZw== 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=fBxzx/ylrxhPN0trHPCae+ajKX9gnnqL7zJbS2wJc6c=; b=bnbxqbgceBmypSy//3TsZWBtvkN8kvwvgjQh+c/BbPj52x0h8Xez+i9WnbmGijmHIM dWEZMBm8u7jWtqp37UwvYXT9wUEyiqkp4aGaUPKGFwkE29B4J51hT0FWOF8C0x2cfb6k KXHhr/m+znG30LugMFTOkfL4wrt3cY4NEwHieTnA5o1/mWzf+Y+eiQgL90iocLyEq3hx fail6CtArH1Xp6vhsZpLyjn1Ne6UZCl7HvLApLIc1+kh7br+431Xis2u7AHZWneBrwVN HnpzhK1GMtmfx/6vZpeCrHhPdJPoT7Qq9W6C1d2dqDX2EW00QJ4yNRS2sse/dYOUlFaQ w+VQ== 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 k6-v6si8523693ith.134.2018.10.08.11.36.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Oct 2018 11:36:14 -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 1g9aM0-0005du-Rp; Mon, 08 Oct 2018 18:34:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g9aLz-0005df-EI for xen-devel@lists.xen.org; Mon, 08 Oct 2018 18:34:03 +0000 X-Inumbo-ID: e82eebbf-cb28-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id e82eebbf-cb28-11e8-a6a9-d7ebe60f679a; Mon, 08 Oct 2018 18:35: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 0B6491596; Mon, 8 Oct 2018 11:34:02 -0700 (PDT) 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 2174C3F5B3; Mon, 8 Oct 2018 11:34:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 8 Oct 2018 19:33:37 +0100 Message-Id: <20181008183352.16291-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008183352.16291-1-julien.grall@arm.com> References: <20181008183352.16291-1-julien.grall@arm.com> Subject: [Xen-devel] [RFC 01/16] 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, andre.przywara@linaro.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 51d2e42c77..9251ae50b8 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -682,8 +682,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 8016cf306f..975c8ff097 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -840,6 +840,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 */ /*