From patchwork Thu Oct 31 15:09:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178190 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980135ill; Thu, 31 Oct 2019 08:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQH/+3B5kB7YjF5/A3EwtTw4wuosDxMsbq5o6DgCCjKc6WsyWpGMRZIu5uGEJvojZYDgo6 X-Received: by 2002:a92:b03:: with SMTP id b3mr7058451ilf.261.1572534676664; Thu, 31 Oct 2019 08:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534676; cv=none; d=google.com; s=arc-20160816; b=dRdn2vw1zxItVIbRhgCB/fctfVaP5K+itfwc8wThfTaod00d1dSepgNeHIJtGNgb90 ID8A1oJ8yxuyDkJwhiU16fUikejqZ53X0ub5KAK3TPMU+d2RzDzVdMEDwHO0sTaAcxUx ghJlYKhQv+7icj2jDgfOrxAko01lA7jTsQZhiOhl0Ix61IaEiNVDdkxLnqq1/VioFVCI PiAguPYwbqT6Zd8Tezq5GT75+Z2cSUgY+lSe5BsyWg/WvnV66EAbFxrZjs797Rcx2Ir0 /Kle0f7R7SFsiXta9kRy56ArKRpdHkjK5uDjRD65yAn7TSITpoHp1epSUGvGK322T6jS ORuQ== 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=6rBY3uL8FxjA7+s8QDm0vtNAc4zmSwvlGUcU5P5pVQo=; b=0fkfK0n2/C8sx1KTL2dQJSlSYdrtXUUfr4XX1jAUibSDEt7YkEBmlWjylFvC51tnMc RoXa1A3sur48jYrxtN+GykJHIiQO+mgetWoqg6RfjBIpQ4KzWreUYIfluqCWYzKkaB/w 6hSHqrV+pTpnh/Euqs2Es2QFpE4mpY9+X2gtpqe9sLEQzx21WQzryk4BZ4IeMW3MMh+d 2sKHgaqGd4YmH/ePBeIxwoeaoypdEORjWmjYXLng/XX0RYmPDd1m/TqrdJR7YA66Tbsk /+BU8g3RGoaVq4eyR0X1br055ZzCZ6/Zjqa5PXSobFuAli9kWOf7exIlDE3Vg5gqf2j9 s5Hg== 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 d67si7752673ilk.99.2019.10.31.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:16 -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 1iQC4t-0006Rt-Uo; Thu, 31 Oct 2019 15:09:35 +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 1iQC4t-0006Ri-Eo for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:35 +0000 X-Inumbo-ID: 728f6340-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 728f6340-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39F7646A; Thu, 31 Oct 2019 08:09:34 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BD6D53F71E; Thu, 31 Oct 2019 08:09:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:04 +0000 Message-Id: <20191031150922.22938-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 01/19] docs/misc: xen-command-line: Remove wrong statement from serrors=diverse 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When serrors=diverse is selected by the user, we will only synchronize the pending SErrors on entry to hypervisor from guest context and exit from guest to hypervisor context. We don't need synchronize SErrors between guest context switch as they would be categorized to Hypervisor generated SErrors in any case. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- The documentation for the option serrors will be fully reworked in a follow-up patch. But the dsb/isb in the context switch will be removed before the documentation rework. So to avoid any question while reviewing the next patch, drop it now. Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Patch added --- docs/misc/xen-command-line.pandoc | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index ef56defef5..30a04df4db 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1877,7 +1877,6 @@ hypervisors handle SErrors: 1. dsb/isb on all EL1 -> EL2 trap entries to categorize SErrors correctly. 2. dsb/isb on EL2 -> EL1 return paths to prevent slipping hypervisor SErrors to guests. - 3. dsb/isb in context switch to isolate SErrors between 2 vCPUs. * `forward`: The hypervisor will not distinguish guest SErrors from hypervisor SErrors. From patchwork Thu Oct 31 15:09:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178197 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980111ill; Thu, 31 Oct 2019 08:11:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa8gGsoyBd3OYt2jnJpN/xX6anDjH5O0AqFGR4VUx51xngQbd92JsgeYQoqgq0YjYh9L4o X-Received: by 2002:a92:5f0a:: with SMTP id t10mr6937650ilb.264.1572534675513; Thu, 31 Oct 2019 08:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534675; cv=none; d=google.com; s=arc-20160816; b=rpqygC6CxIyRcY31OgCqj/180TbpUFKbnMivRdlRSUarI83tNnXlSrHH3YDrAfI3zj xdw6OFI6aSu4ticHE1vpNMAXcVjci+UTG8cAHGoGq81HHiOEPDs2TUvEPqG+0DvwKyBw Y+++e0iCCQGvLy3EqhlN8dy5vKSkhoeheV3KlhnlHm10P4Mvsn9eHJ8ofrAeYEWE/wGo 80/lSRiS1B5g/ycm+dTwWojARqHZvK7UyuJMj3f+41Sr1NM+NlFOgTvmN9f0ZrtNRJIs byLtbyi4yv5+vpwj5GvitW8q7IJ64C2bC2fTqJarL4iVOLxfr0zpI1X48xAEp5Wx9yZ/ EpXA== 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=2soMRsl4/fzjtIzi3k3dnaZrSR1VxYKVMth1q0gCIkY=; b=s+JPTJDso4u94pNWPeDVqeQ9PqkUXCn0wF1ldV5MPkAiw3XAJe+TuUfNVjJjJqKnqh 0q0lG101TVJa6+9xlzW2cw6L03T5EIx5k7dAp/Hx2O/Qwum8r0Uff3Y7btP+IRD++52G AXEQip/JunS2sC0Y79PXe3tMxQgbg/o/xkVGRIjwfh8+s6nrKubrrRGioV9m+ImOcA0r dTUQay+srQJKHk818S4pCWAA/nO7QXBkgVy9XOMbF7db/KRGoGXE7bXc+CTothszCgA9 Sm+0n5byOysuttZzbPbQidffSY41tRhRgqPQlL2oR3cqu02pS1IGgrCggOUy1kQw4BnH XhNA== 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 s26si6825176iol.8.2019.10.31.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:15 -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 1iQC4z-0006Sw-GH; Thu, 31 Oct 2019 15:09:41 +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 1iQC4y-0006SI-9q for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:40 +0000 X-Inumbo-ID: 73b6f0f8-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 73b6f0f8-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 064904F5; Thu, 31 Oct 2019 08:09:36 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E8523F71E; Thu, 31 Oct 2019 08:09:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:05 +0000 Message-Id: <20191031150922.22938-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 02/19] xen/arm: Remove serrors=forward 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Per the Arm ARM (D4.5 in ARM DDI 0487E.a), SError may be precise or imprecise. Imprecise means the state presented to the exception handler is not guaranteed to be consistent with any point in the excution stream from which the exception was taken. In other words, they are likely to be fatal as you can't return safely from them. Without the RAS extension, the Arm architecture does not provide a way to differentiate between imprecise and precise SError. Furthermore Xen has no support for RAS yet. So from a software POV, there is not much we can do. More generally, forwarding blindly SErrors to the guest is likely to be the wrong thing to do. Indeed, Xen is not able to know what is the content of the SError. This may be a critical device used by the hypervisor that is about to fail. In a nutshell, the option serrors=forward is not safe to use in any environment with the current state of Xen. Therefore the option and any code related to it are completely removed. Take the opportunity to rework the comment in do_trap_data_abort() as all SErrors/External Abort generated by the hypervisor will result in a crash of the system no matter what the user passed on the command line. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v4: - Fix grammar - Add Stefano's reviewed-by Changes in v3: - Fix typo in the commit message - Rework comments in arm32/traps.c Changes in v2: - Patch added --- docs/misc/xen-command-line.pandoc | 13 ++----------- xen/arch/arm/arm32/traps.c | 12 ++++++------ xen/arch/arm/domain.c | 11 ----------- xen/arch/arm/traps.c | 34 +++++++--------------------------- xen/include/asm-arm/cpufeature.h | 11 +++++------ 5 files changed, 20 insertions(+), 61 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 30a04df4db..b8a09ce5c4 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1850,7 +1850,7 @@ accidentally leaking secrets by releasing pages without proper sanitization. Set the serial transmit buffer size. ### serrors (ARM) -> `= diverse | forward | panic` +> `= diverse | panic` > Default: `diverse` @@ -1866,7 +1866,7 @@ on the host will not trigger such SErrors. In this case, the administrator can use this parameter to skip categorizing SErrors and reduce the overhead of dsb/isb. -We provided the following 3 options to administrators to determine how the +We provided the following 2 options to administrators to determine how the hypervisors handle SErrors: * `diverse`: @@ -1878,15 +1878,6 @@ hypervisors handle SErrors: 2. dsb/isb on EL2 -> EL1 return paths to prevent slipping hypervisor SErrors to guests. -* `forward`: - The hypervisor will not distinguish guest SErrors from hypervisor SErrors. - All SErrors will be forwarded to guests, except the SErrors generated when - the idle vCPU is running. The idle domain doesn't have the ability to handle - SErrors, so we have to crash the whole system when we get SErros with the - idle vCPU. This option will avoid most overhead of the dsb/isb, except the - dsb/isb in context switch which is used to isolate the SErrors between 2 - vCPUs. - * `panic`: The hypervisor will not distinguish guest SErrors from hypervisor SErrors. All SErrors will crash the whole system. This option will avoid all overhead diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index 76f714a168..9c9790a6d1 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -69,12 +69,12 @@ void do_trap_prefetch_abort(struct cpu_user_regs *regs) void do_trap_data_abort(struct cpu_user_regs *regs) { /* - * We cannot distinguish Xen SErrors from synchronous data aborts. We - * want to avoid treating any Xen synchronous aborts as SErrors and - * forwarding them to the guest. Instead, crash the system in all - * cases when the abort comes from Xen. Even if they are Xen SErrors - * it would be a reasonable thing to do, and the default behavior with - * serror_op == DIVERSE. + * We cannot distinguish between Asynchronous External Abort and + * Synchronous Data Abort. + * + * As asynchronous abort (aka SError) generated by the hypervisor will + * result in a crash of the system (see __do_trap_serror()), it is fine to + * do it here. */ if ( VABORT_GEN_BY_GUEST(regs) ) do_trap_guest_serror(regs); diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 460e968e97..53dc1d11c6 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -353,17 +353,6 @@ void context_switch(struct vcpu *prev, struct vcpu *next) local_irq_disable(); - /* - * If the serrors_op is "FORWARD", we have to prevent forwarding - * SError to wrong vCPU. So before context switch, we have to use - * the SYNCRONIZE_SERROR to guarantee that the pending SError would - * be caught by current vCPU. - * - * The SKIP_CTXT_SWITCH_SERROR_SYNC will be set to cpu_hwcaps when the - * serrors_op is NOT "FORWARD". - */ - SYNCHRONIZE_SERROR(SKIP_CTXT_SWITCH_SERROR_SYNC); - set_current(next); prev = __context_switch(prev, next); diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index a3deb59372..6ed9e66710 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -103,15 +103,12 @@ register_t get_default_hcr_flags(void) static enum { SERRORS_DIVERSE, - SERRORS_FORWARD, SERRORS_PANIC, } serrors_op; static int __init parse_serrors_behavior(const char *str) { - if ( !strcmp(str, "forward") ) - serrors_op = SERRORS_FORWARD; - else if ( !strcmp(str, "panic") ) + if ( !strcmp(str, "panic") ) serrors_op = SERRORS_PANIC; else serrors_op = SERRORS_DIVERSE; @@ -125,9 +122,6 @@ static int __init update_serrors_cpu_caps(void) if ( serrors_op != SERRORS_DIVERSE ) cpus_set_cap(SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT); - if ( serrors_op != SERRORS_FORWARD ) - cpus_set_cap(SKIP_CTXT_SWITCH_SERROR_SYNC); - return 0; } __initcall(update_serrors_cpu_caps); @@ -675,6 +669,9 @@ static void inject_vabt_exception(struct cpu_user_regs *regs) * 3) Hypervisor generated native SError, that would be a bug. * * A true parameter "guest" means that the SError is type#1 or type#2. + * + * Note that Arm32 asynchronous external abort generated by the + * hypervisor will be handled in do_trap_data_abort(). */ static void __do_trap_serror(struct cpu_user_regs *regs, bool guest) { @@ -692,28 +689,11 @@ static void __do_trap_serror(struct cpu_user_regs *regs, bool guest) goto crash_system; } - /* - * The "FORWARD" option will forward all SErrors to the guests, except - * idle domain generated SErrors. - */ - if ( serrors_op == SERRORS_FORWARD ) - { - /* - * Because the idle domain doesn't have the ability to handle the - * SErrors, we have to crash the whole system while we get a SError - * generated by idle domain. - */ - if ( is_idle_vcpu(current) ) - goto crash_system; - - return inject_vabt_exception(regs); - } - crash_system: - /* Three possibilities to crash the whole system: + /* + * Two possibilities to crash the whole system: * 1) "DIVERSE" option with Hypervisor generated SErrors. - * 2) "FORWARD" option with Idle Domain generated SErrors. - * 3) "PANIC" option with all SErrors. + * 2) "PANIC" option with all SErrors. */ do_unexpected_trap("SError", regs); } diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index d06f09ecfa..9af5666628 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -41,13 +41,12 @@ #define ARM64_WORKAROUND_834220 3 #define LIVEPATCH_FEATURE 4 #define SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT 5 -#define SKIP_CTXT_SWITCH_SERROR_SYNC 6 -#define ARM_HARDEN_BRANCH_PREDICTOR 7 -#define ARM_SSBD 8 -#define ARM_SMCCC_1_1 9 -#define ARM64_WORKAROUND_AT_SPECULATE 10 +#define ARM_HARDEN_BRANCH_PREDICTOR 6 +#define ARM_SSBD 7 +#define ARM_SMCCC_1_1 8 +#define ARM64_WORKAROUND_AT_SPECULATE 9 -#define ARM_NCAPS 11 +#define ARM_NCAPS 10 #ifndef __ASSEMBLY__ From patchwork Thu Oct 31 15:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178187 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980073ill; Thu, 31 Oct 2019 08:11:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0juh5uyS0ZBzyzUACJHx5GOmXYr2ZWJWffUiGqqYdF3JpJbcrrbYbRMe4rkpt6YfXMYmv X-Received: by 2002:a92:bbd1:: with SMTP id x78mr2927169ilk.149.1572534674328; Thu, 31 Oct 2019 08:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534674; cv=none; d=google.com; s=arc-20160816; b=IhY0iZpWjFSuYj4IHgEl3Kht5jq0mVIvjiu6lsemaqbOwJOjICQNYooHWHY6Vgeiol h24b7kdMua2Nl1hmb1IK1AkFJ85/vSQ2dJ/BYllsU6ocF2rAwkvZOyQ6w/FW86YUfjOz XgbDKwc+PcpG3S7LDUA1CjM78uZY77T8xVr5uW7k3d7eeUI+sEZgryF6oA/3RegxKzq8 SJR0uhyFeDN3JAKPnR4Ydrd1LS1kfbbccpSKo5tnDxlH8aZuHMUCi+GMAQKJbKZbv9v3 wzjngHWtvRWdsm25Ebgz7GGLfHyzYuRhqUXS0IqdtE6WXio4Kqa809WfgPmGqgZZB3oY 1Xkw== 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=daMAOLdD37HyoxWTKEzGCANW4a1C7n5/sdad1nT06OA=; b=dk3XyshL65CJEgVMtGLMPazwDguLaZ21KejZoqdANIhD4LUdnxlAOBnLKOTXzO3eOS bU6GtF7Y+bCX7MxKVIgp2egGOeZ25iHYzTU9l1kIUqxAhgfgGSZZ1+tmuptRF1FXrOmW 0zTni4XCrAtf/FwmVlmEgTqHY1JhH97CP88adaiC6kXk1vyRO1uRN/YOpdoL3qzjuw7j /NQ/LF7in3s+rKSpvJyJsszQCNUKRGYl88n54z4XSxPZPIn1dbNqRcCh7PG3Mx4Cb0Jd Q2Fyihpp1UpX7arMCaLzSumdR7ehZy+KI4DcXiEdBTv6/xZZktfTNCjmYoB0eSkgKj19 ExqA== 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 y102si1674926jah.88.2019.10.31.08.11.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11: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 1iQC4y-0006SF-6J; Thu, 31 Oct 2019 15:09:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC4x-0006S8-Bg for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:39 +0000 X-Inumbo-ID: 7460388e-fbf0-11e9-a531-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 7460388e-fbf0-11e9-a531-bc764e2007e4; Thu, 31 Oct 2019 15:09:37 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 22F8255D; Thu, 31 Oct 2019 08:09:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B1C63F71E; Thu, 31 Oct 2019 08:09:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:06 +0000 Message-Id: <20191031150922.22938-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 03/19] xen/arm: traps: Rework __do_serror() documentation 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The documentation on top of __do_serror() is trying to describe all the possibilities to receive an SErrors. The description of type#2 is quite misleading because receiving an SError in EL2 after unmasking SError interrupt ({PSTATE, CPSR}.A) does not necessarily imply the SError were generated by the guest. You also need to be in a special window (see abort_guest_exist_{guest, end}). However, for the context of the function it does not matter how we categorize the interrupts. What matter is to know whether this is a guest-generated SError. All the documentation of __do_serror() is now reworked to avoid misleading information. Take the opportunity to simplify the code after the forward option has been dropped. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v3: - Fix typo - Add Stefano's acked-by Changes in v2: - Patch added --- xen/arch/arm/traps.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 6ed9e66710..3262052f47 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -660,41 +660,31 @@ static void inject_vabt_exception(struct cpu_user_regs *regs) } /* - * SError exception handler. We only handle the following 3 types of SErrors: - * 1) Guest-generated SError and had been delivered in EL1 and then - * been forwarded to EL2. - * 2) Guest-generated SError but hadn't been delivered in EL1 before - * trapping to EL2. This SError would be caught in EL2 as soon as - * we just unmasked the PSTATE.A bit. - * 3) Hypervisor generated native SError, that would be a bug. + * SError exception handler. * * A true parameter "guest" means that the SError is type#1 or type#2. * + * @guest indicates whether this is a SError generated by the guest. + * + * If true, the SError was generated by the guest, so it is safe to continue + * and forward to the guest (if requested). + * + * If false, the SError was likely generated by the hypervisor. As we cannot + * distinguish between precise and imprecise SErrors, it is not safe to + * continue. + * * Note that Arm32 asynchronous external abort generated by the * hypervisor will be handled in do_trap_data_abort(). */ static void __do_trap_serror(struct cpu_user_regs *regs, bool guest) { /* - * Only "DIVERSE" option needs to distinguish the guest-generated SErrors - * from hypervisor SErrors. + * When using "DIVERSE", the SErrors generated by the guest will be + * forwarded to the currently running vCPU. */ - if ( serrors_op == SERRORS_DIVERSE ) - { - /* Forward the type#1 and type#2 SErrors to guests. */ - if ( guest ) + if ( serrors_op == SERRORS_DIVERSE && guest ) return inject_vabt_exception(regs); - /* Type#3 SErrors will panic the whole system */ - goto crash_system; - } - -crash_system: - /* - * Two possibilities to crash the whole system: - * 1) "DIVERSE" option with Hypervisor generated SErrors. - * 2) "PANIC" option with all SErrors. - */ do_unexpected_trap("SError", regs); } From patchwork Thu Oct 31 15:09:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178196 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980114ill; Thu, 31 Oct 2019 08:11:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0gE3437IYufxb8gBmKfchROiYpMHa+nY/4guZ6xeOvsy9KPSSNYKbToICVP9k2oRQ2tTJ X-Received: by 2002:a6b:3707:: with SMTP id e7mr5702459ioa.293.1572534675660; Thu, 31 Oct 2019 08:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534675; cv=none; d=google.com; s=arc-20160816; b=iRB6yi8zskw2M9nsdevF0GyvIYDynBQoveiWy0YqZSOjd0o4zUw1/liJfY1D0K9UCb cE1bsF01JETu7RHkd2UqIDS6tWfv0IbqmjhNPcjpXZp4p6urS/xMyAKz+8aSKei3MCLy Ppz6F02tn1Dj5M6Q8FSb0bpf/SY4x5pP4Dy0V3wsausCTW7TQAcTuzCs9+KlgFxOsqL+ 5W7ykKuB+y7zB/06yrSvix823+EUbGwItETCSJZ/rUjCUb3jvCqEGtJta4NCyQ3JyVry lJUVHsIPsYRLnhJYYr6QQMGBPUrRA2+ptbnP6lDH2A/J4m+vN4ZYnhcgke63D0MU+jhk HRAA== 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=MXgrSx+q70ckAQ+5ZzuH+dRcmTCDcqhb6LhQPb1gnvY=; b=YK/w7qIciw9/mp1nAg9OST3L+RuOpIObjI6R7R34rHH0FbQIHCSYOHVUKYI4Sd/5J9 Weh89zT+u0BjZvSPlHtVmZy9KEdB6sp25FUtHmudzOcQ6HgUg35qyk5e+LmAT99uASH9 A+hSfHiZDTPmuQyGV+EHCd34xKKzEXC/6bjxViNofLevVC1+OijayXTKX90PBt1BuQQz aRF/FtRhHpSlN/tCF3MihN4EEyUqV4PStiqvn7M98AJo45fXx+/PqXsQefSdD4wk7shT vsjgVsh9x+Xh1Je+D0cdhDTBRivW/ZhdxDQovGxboEhs6PnA7weela05hEST3xvdaHUH 2eIQ== 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 i8si7202933ioa.56.2019.10.31.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:15 -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 1iQC54-0006Uw-8d; Thu, 31 Oct 2019 15:09:46 +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 1iQC53-0006UR-9z for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:45 +0000 X-Inumbo-ID: 754ef15e-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 754ef15e-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:39 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C79D646A; Thu, 31 Oct 2019 08:09:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 58BE53F71E; Thu, 31 Oct 2019 08:09:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:07 +0000 Message-Id: <20191031150922.22938-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 04/19] docs/misc: xen-command-line: Rework documentation of the option 'serrors' 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Julien Grall , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The current documentation is misleading for a few reasons: 1) The synchronization happens on all exit/entry from/to the guest. This includes from EL0 (i.e userspace). 2) Trusted guest can also generate SErrors (e.g. memory failure) 3) Without RAS support, SErrors are IMP DEFINED. Unless you have a complete TRM in hand, you can't really make a decision. 4) The documentation is written around performance when this is not the first concern. The documentation is now reworked to focus on the consequences of using serrors="panic" and avoid to go in details on the exact implementation. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- TBH, I think this was a mistake to introduce more options without understanding the real use case from the users and the impact. I am not totally against serrors="panic" but I don't think this can be safely used by anyone withtout having a TRM in hand that exhaustively describes all the SErrors. Changes in v4: - Add Stefano's acked-by Changes in v2: - Patch added --- docs/misc/xen-command-line.pandoc | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index b8a09ce5c4..451d213c8c 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1854,34 +1854,19 @@ Set the serial transmit buffer size. > Default: `diverse` -This parameter is provided to administrators to determine how the -hypervisors handle SErrors. - -In order to distinguish guest-generated SErrors from hypervisor-generated -SErrors we have to place SError checking code in every EL1 <-> EL2 paths. -That will cause overhead on entries and exits due to dsb/isb. However, not all -platforms need to categorize SErrors. For example, a host that is running with -trusted guests. The administrator can confirm that all guests that are running -on the host will not trigger such SErrors. In this case, the administrator can -use this parameter to skip categorizing SErrors and reduce the overhead of -dsb/isb. - -We provided the following 2 options to administrators to determine how the -hypervisors handle SErrors: +This parameter is provided to administrators to determine how the hypervisor +handles SErrors. * `diverse`: - The hypervisor will distinguish guest SErrors from hypervisor SErrors. - The guest generated SErrors will be forwarded to guests, the hypervisor - generated SErrors will cause the whole system to crash. - It requires: - 1. dsb/isb on all EL1 -> EL2 trap entries to categorize SErrors correctly. - 2. dsb/isb on EL2 -> EL1 return paths to prevent slipping hypervisor - SErrors to guests. + The hypervisor will distinguish guest SErrors from hypervisor SErrors: + - The guest generated SErrors will be forwarded to the currently running + guest. + - The hypervisor generated SErrors will cause the whole system to crash * `panic`: - The hypervisor will not distinguish guest SErrors from hypervisor SErrors. - All SErrors will crash the whole system. This option will avoid all overhead - of the dsb/isb pairs. + All SErrors will cause the whole system to crash. This option should only + be used if you trust all your guests and/or they don't have a gadget (e.g. + device) to generate SErrors in normal run. ### shim_mem (x86) > `= List of ( min: | max: | )` From patchwork Thu Oct 31 15:09:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178191 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980153ill; Thu, 31 Oct 2019 08:11:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWdLkETwR52dj6lzKGnlqDKcvrb89zRCyprB6L92N19Xt96IXrlqHNtz9lo9Plqf3zLYi+ X-Received: by 2002:a02:6ccf:: with SMTP id w198mr957065jab.22.1572534677116; Thu, 31 Oct 2019 08:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534677; cv=none; d=google.com; s=arc-20160816; b=1HkH5oUhGBT9LWjdJqvOm3VvSheEFpZKklvkvxbC0mdS1yFxR7lBz2SQa4q+1LLrCb 3N134WcLAy/fT7pms3TKlfD67BOdKKJELgF7pd9JZOiTIXBHsN1yiFxKIr9pKkm9uUHE Bbv+axo0keiK7EkE4byI4caagFPFVHvNRB9lZy6BaqajeV4+tLLbh5S44/UrxgjQMbur SS7+oMZ9DgwHpugNk9V4LhQGSdRv95ZDntbfC/Zw8Y9ADZ4NaUlq+020fJJOdSdylUlr IVAm4nM5T94quRlEC+PljI0FabiwFRKsFthkMcIqseg+thVo9P74Og0bXeY+rQ0W5VVC wHlA== 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=+Ou5PfEyktNMLxckO452XbKRYpIgVrkliWWQBxquBQE=; b=KfyYs4NsHsQx13HM3OZBMn/cEekKc9WEK7Xa225FfDCUFS3snNcNTLV4BYX+nGhUl4 OYMzf0u2g3f9Oo/BrdrtUaOKb/kmSZcauZA3bwJ9CJ19WvlVuY6C0ylX9Oqfquc3Zo0h grLiF3s9PfKHF2knp2pgfMxZ8uFva/IsCkWfHB+/16rjQfg1GpM8jQNOMQT2c8dyZatD OHzG4nNug85BkOtYH5Cu5G9Q7ogneXl++pACxST7I6VpCLVXF4OdVBVhkxJRBxMzMs6S 0iJuenZ0/lPVz/e04vkPz08fDYJZdpunyIdv0e/g3VpXj/mufu0hNwnKZ0GJ0718syuC Wx2Q== 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 w9si8695329jaf.115.2019.10.31.08.11.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:17 -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 1iQC59-0006Yd-Uc; Thu, 31 Oct 2019 15:09:51 +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 1iQC58-0006XN-Ad for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:50 +0000 X-Inumbo-ID: 75fbf34a-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 75fbf34a-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:40 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E7B76625; Thu, 31 Oct 2019 08:09:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 085003F71E; Thu, 31 Oct 2019 08:09:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:08 +0000 Message-Id: <20191031150922.22938-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 05/19] xen/arm: traps: Update the correct PC when inject a virtual SError to the guest 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When injecting a virtual Abort to the guest, we want to update the guest PC so it can re-execute the HVC/SMC once it has handled the SError. This is unfortunately not the case when the SError is synchronized on entry from the guest. As the SError will be received while running in hypervisor context, we will update the PC of hypervisor context (i.e the trap). Rework inject_vabt_exception so it uses the guest context rather than the current one. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Technically, updating the PC is only necessary when guest SError are received while running in hypervisor. The code should be reworked to get the path a bit simpler, but this is post Xen 4.13 work. Changes in v4: - Add Stefano's acked-by Changes in v3: - s/vcpu_info/vcpu/ Changes in v2: - Add patch --- xen/arch/arm/traps.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 3262052f47..12c52a3860 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -629,11 +629,18 @@ static void inject_dabt_exception(struct cpu_user_regs *regs, #endif } -/* Inject a virtual Abort/SError into the guest. */ -static void inject_vabt_exception(struct cpu_user_regs *regs) +/* + * Inject a virtual Abort/SError into the guest. + * + * This should only be called with 'current'. + */ +static void inject_vabt_exception(struct vcpu *v) { + struct cpu_user_regs *regs = guest_cpu_user_regs(); const union hsr hsr = { .bits = regs->hsr }; + ASSERT(v == current); + /* * SVC/HVC/SMC already have an adjusted PC (See ARM ARM DDI 0487A.j * D1.10.1 for more details), which we need to correct in order to @@ -656,7 +663,7 @@ static void inject_vabt_exception(struct cpu_user_regs *regs) break; } - vcpu_hcr_set_flags(current, HCR_VA); + vcpu_hcr_set_flags(v, HCR_VA); } /* @@ -683,7 +690,7 @@ static void __do_trap_serror(struct cpu_user_regs *regs, bool guest) * forwarded to the currently running vCPU. */ if ( serrors_op == SERRORS_DIVERSE && guest ) - return inject_vabt_exception(regs); + return inject_vabt_exception(current); do_unexpected_trap("SError", regs); } From patchwork Thu Oct 31 15:09:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178194 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980254ill; Thu, 31 Oct 2019 08:11:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVA5/EkEqqvvBHPYSC2XrmRbi1Z9d3z3XeZ7SHMyaqnegZrlkFsKlafGUPSGDlEpbgMnWu X-Received: by 2002:a92:358e:: with SMTP id c14mr2889188ilf.234.1572534681660; Thu, 31 Oct 2019 08:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534681; cv=none; d=google.com; s=arc-20160816; b=dWG6MfVem6N38GUqndRaKO2+/od7XycD2ImwELwn080GA4WAGCWFP0fA3bIaZvlFtu OsJwuVfQnH/cY2v6HJcqEg/B2mnUea8q4Xpl3MVYrHifbbTMTW+CD/4f+iJq2wkvuYI2 iJ9py/A5TWYIW1rTVflOIDCsdb3ABGfk0uw8JHKvKC8r8LxxnvDar73c/ryUIoUJfLPM PP5CiAFy57+KLUm/dC34pLtbWGHfLxdMYvTv3gUGo8muM7s3xWujsIr91mNUXUNmvVyy RRvLdgqFj1Z3/2W7NbL9y/5CvfUuTtCJcYyO+h2Ne6paCg9tSqgZzStFA/A06uzOLXMy ZvOQ== 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=0ulMyYHbO0A+z4U6laTfRnmGBcCmJEOpIYj/Iyv97Ek=; b=XmhHlx95RxO6PWCunzxUL0Dew/SkUx3WOTTQRUYVJMx1X927QQdHdgHOPrCm8J1qTt P+y597j4P1Qa/aye1r1BcMESAMmYhaSoxGeaEqYzN8ioIDBIGHZyc3fIYTgYtFZY8sY7 w2igFbBOn/+wWOGwZOSHiC4jrj33JAne98v56TtAnL73xBdl1clk6qlQQO4Xqeme0aSR J5UC0OKv4T2eGKx2HVXHF3b7MPSeXIdJhrhvPMeL8AuaksUruzWpFIvRQQvY7sV7J1Io Kt9gNRwLB9WrQ1F4Ae63E/aWUR+xIVDJZ/shvsc7NH1CAGU/I1AbRggbT75bYcTkeYTJ yVdg== 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 d62si7257886iog.25.2019.10.31.08.11.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:21 -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 1iQC5E-0006cZ-Jk; Thu, 31 Oct 2019 15:09:56 +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 1iQC5D-0006bE-A4 for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:55 +0000 X-Inumbo-ID: 768f7188-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 768f7188-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:41 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 130AD64F; Thu, 31 Oct 2019 08:09:41 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2887C3F71E; Thu, 31 Oct 2019 08:09:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:09 +0000 Message-Id: <20191031150922.22938-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 06/19] xen/arm64: entry: Avoid open-coding interrupt flags 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, the interrupts to mask/unmask are hardcoded in the code making more difficult to find out what's going on. A new series of short-hand specific to the file entry.S is now added. The name of the short-hands should tell which interrupts will be changed by the msr daif{set, clr} instructions. Take the opportunity to replace the hardcoded values with the new short-hands. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Patch added --- xen/arch/arm/arm64/entry.S | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 3e41ba65b6..fac4655bb9 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -6,6 +6,24 @@ #include #include +#define IFLAGS_D_BIT 8 +#define IFLAGS_A_BIT 4 +#define IFLAGS_I_BIT 2 +#define IFLAGS_F_BIT 1 + +/* + * Short-hands to define the interrupts (D, A, I, F) + * + * _ means the interrupt state will not change + * X means the state of interrupt X will change + * + * To be used with msr daif{set, clr} only. + * + */ +#define IFLAGS__AI_ IFLAGS_A_BIT | IFLAGS_I_BIT +#define IFLAGS__A__ IFLAGS_A_BIT +#define IFLAGS___I_ IFLAGS_I_BIT + /* * Stack pushing/popping (register pairs only). Equivalent to store decrement * before, load increment after. @@ -338,7 +356,7 @@ guest_sync_slowpath: ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #6 + msr daifclr, #IFLAGS__AI_ mov x0, sp bl do_trap_guest_sync 1: @@ -354,7 +372,7 @@ guest_irq: ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #4 + msr daifclr, #IFLAGS__A__ mov x0, sp bl do_trap_irq 1: @@ -366,7 +384,7 @@ guest_fiq_invalid: guest_error: entry hyp=0, compat=0 - msr daifclr, #6 + msr daifclr, #IFLAGS__AI_ mov x0, sp bl do_trap_guest_serror exit hyp=0, compat=0 @@ -381,7 +399,7 @@ guest_sync_compat: ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #6 + msr daifclr, #IFLAGS__AI_ mov x0, sp bl do_trap_guest_sync 1: @@ -397,7 +415,7 @@ guest_irq_compat: ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #4 + msr daifclr, #IFLAGS__A__ mov x0, sp bl do_trap_irq 1: @@ -409,7 +427,7 @@ guest_fiq_invalid_compat: guest_error_compat: entry hyp=0, compat=1 - msr daifclr, #6 + msr daifclr, #IFLAGS__AI_ mov x0, sp bl do_trap_guest_serror exit hyp=0, compat=1 @@ -420,7 +438,7 @@ ENTRY(return_to_new_vcpu64) exit hyp=0, compat=0 return_from_trap: - msr daifset, #2 /* Mask interrupts */ + msr daifset, #IFLAGS___I_ /* Mask interrupts */ ldr x21, [sp, #UREGS_PC] /* load ELR */ ldr w22, [sp, #UREGS_CPSR] /* load SPSR */ @@ -471,7 +489,7 @@ check_pending_vserror: * SError, the EL2 error exception will happen after PSTATE.A * is cleared. */ - msr daifclr, #4 + msr daifclr, #IFLAGS__A__ /* * This is our single instruction exception window. A pending @@ -490,7 +508,7 @@ abort_guest_exit_start: .global abort_guest_exit_end abort_guest_exit_end: /* Mask PSTATE asynchronous abort bit, close the checking window. */ - msr daifset, #4 + msr daifset, #IFLAGS__A__ /* * Compare elr_el2 and the saved value to check whether we are From patchwork Thu Oct 31 15:09:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178186 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980072ill; Thu, 31 Oct 2019 08:11:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx46X3sRmfGiXonkmDs29Kn6m5glDujr+9tm1SW9EyeJtlhFkokoN6u7laI1WYymLQOfoqE X-Received: by 2002:a05:6638:9:: with SMTP id z9mr1551681jao.95.1572534674267; Thu, 31 Oct 2019 08:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534674; cv=none; d=google.com; s=arc-20160816; b=bAzljbE+1wJNnCUDe99QnsOcnpLHwGFDTweXA5MLzBiJbCP4810ZiDcpKVUNehTbNw SDchOG88Xll8At1mtHLh0VfDAlW3BODYMV62gAb7DNJhpqFocbx4THEFraDNilHL7FNn 1+5a94+DzqJZNKdYdzVs6mHZvTVIsyai0PE92P0FGcUqMGZI+9TJzi4/nW1ZAyUPR5eS Fd3V9+N5+bf4fUSsKFQzVx0lP8ZY7sNZVkyoi7qaN6Uj8E1kFTgJ/yWxAZn6NlnsYQP3 xj91d+UwNdcPArTHFUf8IhhEwk9hzaBx7j1XAv073mAQk9oMDliz7MbB0axlZbA4V+sb kPgA== 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=aYurCRELM+EBTGHAkv+IxbO/nCrhaA3SS7VpgeWhiP8=; b=tPWDL0q4OmcKiIoRvA2S8T0PhmdHeE1dwKkL8T7klpEcm5wzlCKHi2koadhJ/34xjS YsBMfkcljucXX2GqAqzUGXSclnznHr3Nl7ArMZCe5qwQotJYju1tK6sBidnMS3dN6WWX LuWhoMu9BK84Kr80wlEBtSf0btv5ssUFmbwu/KpsF3uC6HgzRHQr3EZub2kFeZ81nYJX pA68eMOexDf0NBfkvlh2dMXLibyX2ieBRPaUBYcxmLnWEKM0ObkyJ/FFq6SqzBuaUjeA pXmWhHv5IsZEa+/foSVzgzZn3C9yimX4GYbi6mz7Mvwf3tG+UI+KGx8RZFuqwPXmeKXi Hxuw== 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 i10si7959176iog.52.2019.10.31.08.11.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11: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 1iQC53-0006Uc-Uq; Thu, 31 Oct 2019 15:09:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC52-0006UA-BE for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:44 +0000 X-Inumbo-ID: 77562ff8-fbf0-11e9-8aca-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 77562ff8-fbf0-11e9-8aca-bc764e2007e4; Thu, 31 Oct 2019 15:09:42 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 31CC446A; Thu, 31 Oct 2019 08:09:42 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 48F053F71E; Thu, 31 Oct 2019 08:09:41 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:10 +0000 Message-Id: <20191031150922.22938-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 07/19] xen/arm64: entry: Introduce a macro to generate guest vector and use it 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Most of the guest vectors are using the same pattern. This makes fairly tedious to alter the pattern and risk introducing mistakes when updating each path. A new macro is introduced to generate the guest vectors and now use it in the one that use the open-code version. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Use the new short-hands --- xen/arch/arm/arm64/entry.S | 84 ++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 56 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index fac4655bb9..2867c499da 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -175,6 +175,30 @@ .endm + /* + * Generate a guest vector. + * + * iflags: Correspond to the list of interrupts to unmask + * save_x0_x1: See the description on top of the macro 'entry' + */ + .macro guest_vector compat, iflags, trap, save_x0_x1=1 + entry hyp=0, compat=\compat, save_x0_x1=\save_x0_x1 + /* + * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + * is not set. If a vSError took place, the initial exception will be + * skipped. Exit ASAP + */ + ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", + "nop; nop", + SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) + msr daifclr, \iflags + mov x0, sp + bl do_trap_\trap +1: + exit hyp=0, compat=\compat + .endm + + /* * Bad Abort numbers *----------------- @@ -347,36 +371,10 @@ guest_sync_slowpath: * x0/x1 may have been scratch by the fast path above, so avoid * to save them. */ - entry hyp=0, compat=0, save_x0_x1=0 - /* - * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * is not set. If a vSError took place, the initial exception will be - * skipped. Exit ASAP - */ - ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", - "nop; nop", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #IFLAGS__AI_ - mov x0, sp - bl do_trap_guest_sync -1: - exit hyp=0, compat=0 + guest_vector compat=0, iflags=IFLAGS__AI_, trap=guest_sync, save_x0_x1=0 guest_irq: - entry hyp=0, compat=0 - /* - * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * is not set. If a vSError took place, the initial exception will be - * skipped. Exit ASAP - */ - ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", - "nop; nop", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #IFLAGS__A__ - mov x0, sp - bl do_trap_irq -1: - exit hyp=0, compat=0 + guest_vector compat=0, iflags=IFLAGS__A__, trap=irq guest_fiq_invalid: entry hyp=0, compat=0 @@ -390,36 +388,10 @@ guest_error: exit hyp=0, compat=0 guest_sync_compat: - entry hyp=0, compat=1 - /* - * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * is not set. If a vSError took place, the initial exception will be - * skipped. Exit ASAP - */ - ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", - "nop; nop", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #IFLAGS__AI_ - mov x0, sp - bl do_trap_guest_sync -1: - exit hyp=0, compat=1 + guest_vector compat=1, iflags=IFLAGS__AI_, trap=guest_sync guest_irq_compat: - entry hyp=0, compat=1 - /* - * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * is not set. If a vSError took place, the initial exception will be - * skipped. Exit ASAP - */ - ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", - "nop; nop", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) - msr daifclr, #IFLAGS__A__ - mov x0, sp - bl do_trap_irq -1: - exit hyp=0, compat=1 + guest_vector compat=1, iflags=IFLAGS__A__, trap=irq guest_fiq_invalid_compat: entry hyp=0, compat=1 From patchwork Thu Oct 31 15:09:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178198 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980154ill; Thu, 31 Oct 2019 08:11:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUX3Ie53rNili419C9c8hsPrqMdwIGng3TtUKK7dUdaac6QawkrUrRn7pO8Zl6wTr2bght X-Received: by 2002:a5d:9059:: with SMTP id v25mr5307333ioq.58.1572534677192; Thu, 31 Oct 2019 08:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534677; cv=none; d=google.com; s=arc-20160816; b=K2FC02xxu4fJ2RW3jD8s8T35Rl8nT/dApYzeNPa4N/qula9SQLmfwr9nMaFPvWt/g1 ZQf6LZJ8QOpFkD89Lw0UploO/0kKsdMqV7agARqsR81hWnWFRLELxTg1EzR0T9CN43D5 7Pe8tFOIzkunrZrDIOpC/YD03KLW2+P00JEJCIQOOoP+Nb6dTV9iolUUXeZ9n2VsXlU/ xWJF48H9GcMqHuniirM59lZjAEBAFLr1dWlhcvGo8tFp77R8Ajm1bmz0zP/SLdb3KmE2 MIeKjZTzi1sEiweKrdHxyb6ChtpDk6jUk2edZNoLUIGtAtPihBfdyis8przWSJgqdFs3 1lSg== 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=fTz0HATC195JmE1Ve91RC73QX4s6IhXdLT+g4B9v6OQ=; b=TsmgEUNQr0KZPUmkmkcxduQCWGGUVZx1CTa31KfyFXVFZDNsszV9EcA5mZtq7bwjbc l74scuQKpPKDXp1YDDXsKRcRMh8QzO+1NL7GZi4b+QXGruWF16DOpr/1WWH6A/j2/jup oRjJoFAiv8IPdOp3nzPE+eB8vVyfcYUmMyj4tXd10RK1OyUj4Rqo4/CKpu63TbJbqD61 6pi//+l2jbSvyAsuZs8IDRVkUsRjU5a0IR48I8iptCYV//2UWexjKEXF32JZC9QTypy4 BWznGIVYDe6LifcatWs+3xmf/UNlgHzT0u96jQnOLoWwGgwxefGL8g3sbHD+ujTapd2u m+4Q== 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 j19si7377660ioo.134.2019.10.31.08.11.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:17 -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 1iQC58-0006Xc-Jo; Thu, 31 Oct 2019 15:09:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC57-0006Wv-Bt for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:49 +0000 X-Inumbo-ID: 77ea8f2c-fbf0-11e9-bbab-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 77ea8f2c-fbf0-11e9-bbab-bc764e2007e4; Thu, 31 Oct 2019 15:09:43 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4E3F74F5; Thu, 31 Oct 2019 08:09:43 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6682C3F71E; Thu, 31 Oct 2019 08:09:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:11 +0000 Message-Id: <20191031150922.22938-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 08/19] xen/arm64: entry: Check if an SError is pending when receiving a vSError 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, when we receive an SError exception from the guest, we don't check if there are any other pending. For hardening the code, we should ensure any pending SError are accounted to the guest before executing any code with SError unmasked. The recently introduced macro 'guest_vector' could used to generate the two vectors and therefore take advantage of any change required in the future. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Title: s/head/entry/ - Use the new short-hands --- xen/arch/arm/arm64/entry.S | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 2867c499da..d94c13e7bf 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -381,11 +381,7 @@ guest_fiq_invalid: invalid BAD_FIQ guest_error: - entry hyp=0, compat=0 - msr daifclr, #IFLAGS__AI_ - mov x0, sp - bl do_trap_guest_serror - exit hyp=0, compat=0 + guest_vector compat=0, iflags=IFLAGS__AI_, trap=guest_serror guest_sync_compat: guest_vector compat=1, iflags=IFLAGS__AI_, trap=guest_sync @@ -398,11 +394,7 @@ guest_fiq_invalid_compat: invalid BAD_FIQ guest_error_compat: - entry hyp=0, compat=1 - msr daifclr, #IFLAGS__AI_ - mov x0, sp - bl do_trap_guest_serror - exit hyp=0, compat=1 + guest_vector compat=1, iflags=IFLAGS__AI_, trap=guest_serror ENTRY(return_to_new_vcpu32) exit hyp=0, compat=1 From patchwork Thu Oct 31 15:09:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178199 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980466ill; Thu, 31 Oct 2019 08:11:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFDJduIF+Hi7436RnTCMdgDjYMRkC7cNWERk79PMXGqA3dTCFWatP87FJ+f+uLY2m0/1gd X-Received: by 2002:a6b:9245:: with SMTP id u66mr5524545iod.98.1572534690774; Thu, 31 Oct 2019 08:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534690; cv=none; d=google.com; s=arc-20160816; b=fCURYd2qPAMD96EXFcrHzleGnQhq9hDq5qG00SvuLuRIElJSivOMlq5BTVo7cp3JQO w4Em0awDsQxuV4GwOYsX8AMaVWRahz+Z2rmBwAyC/ZDvteLZ3oZUAAmY569FyZT+wG4A FL16M8jfe6CIqI1QXCRmH+4YjI/FSrF/DFCdO5ns72qSKlrkwXH8Os0VFep8yALL/dWv oimFusu7JVgvm7JP0FgkZsIH6xivBfz4DCIt8y46vLg3UpLCadqNdbMCSDa3oMLa0xsp h0qujXoxT0HdKM/ZgVGIVByDS5pUn0pt1amNQ93+Dr+tQzepB9MsoM9mtSHzBRNNscOq WXag== 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=7runUlP1Nk1EmjGmCEuE7sEdIGG+cyukc2P9Wox5rps=; b=FewxjZOaZznRh5MXQwDLR+vobbZCYwMTHafFAj4WL7uEt04/ItUaS1J9aLLeVUtSMZ 1h0d0qV+A37rIu5sqvP8UWjbcdXiPWgTAJYayAxiY0hQhK0NY4SslFQ4f/67yA6oTiXs t+KNR1f/QTkISPcjykH04Okf1uZosaMeVvD0PtkUi49onh3Ln6bBb9+PY+YpvPfGBP7L /xK8cRiQfJNy5IyBzLx/pxhU8fRBNLntYHFYyU3PGRhEvWJ02mFSuffZpoCYGj+gkPBx GoX4uWeaMeDv+rD++lc7bakMF5pkvVzGC0NpUK3ZGYvTk82W0arLd4fWsZtKT1VNiqz7 EM+g== 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 t14si3264337ioj.81.2019.10.31.08.11.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:30 -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 1iQC5J-0006hq-HV; Thu, 31 Oct 2019 15:10:01 +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 1iQC5I-0006gP-AQ for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:00 +0000 X-Inumbo-ID: 7898abd4-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7898abd4-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:44 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C0C868D; Thu, 31 Oct 2019 08:09:44 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 831D33F71E; Thu, 31 Oct 2019 08:09:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:12 +0000 Message-Id: <20191031150922.22938-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 09/19] xen/arm: traps: Rework entry/exit from the guest path 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, enter_hypervisor_head() and leave_hypervisor_tail() are used to deal with actions to be done before/after any guest request is handled. While they are meant to work in pair, the former is called for most of the traps, including traps from the same exception level (i.e. hypervisor) whilst the latter will only be called when returning to the guest. As pointed out, the enter_hypervisor_head() is not called from all the traps, so this makes potentially difficult to extend it for the dealing with same exception level. Furthermore, some assembly only path will require to call enter_hypervisor_tail(). So the function is now directly call by assembly in for guest vector only. This means that the check whether we are called in a guest trap can now be removed. Take the opportunity to rename enter_hypervisor_tail() and leave_hypervisor_tail() to something more meaningful and document them. This should help everyone to understand the purpose of the two functions. Note that enter_hypervisor_tail() does not take any parameters anymore as after the rework, the code does not use them anymore. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v4: - Add Stefano's acked-by Changes in v3: - Update the documentation on the callee side of leave_hypervisor_to_guest(). - Replace "interrupts" with "IRQ" Changes in v2: - Update in-code comment - Remove 'regs' parameter from enter_hypervisor_tail() - Add arm32 code --- xen/arch/arm/arm32/entry.S | 5 +++- xen/arch/arm/arm64/entry.S | 3 +- xen/arch/arm/traps.c | 71 ++++++++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index ec90cca093..5abff24e91 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -177,6 +177,9 @@ skip_check: .if \guest_iflags != n cpsie \guest_iflags .endif + + bl enter_hypervisor_from_guest + 2: /* We are ready to handle the trap, setup the registers and jump. */ adr lr, return_from_trap @@ -332,7 +335,7 @@ ENTRY(return_to_new_vcpu32) return_to_guest: mov r11, sp bic sp, #7 /* Align the stack pointer */ - bl leave_hypervisor_tail /* Disables interrupts on return */ + bl leave_hypervisor_to_guest /* Mask IRQ on return */ mov sp, r11 RESTORE_ONE_BANKED(SP_usr) /* LR_usr is the same physical register as lr and is restored below */ diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index d94c13e7bf..97dc60210d 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -165,7 +165,7 @@ .if \hyp == 0 /* Guest mode */ - bl leave_hypervisor_tail /* Disables interrupts on return */ + bl leave_hypervisor_to_guest /* Mask IRQ on return */ exit_guest \compat @@ -192,6 +192,7 @@ "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) msr daifclr, \iflags + bl enter_hypervisor_from_guest mov x0, sp bl do_trap_\trap 1: diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 12c52a3860..adbedc2d15 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1984,47 +1984,46 @@ static inline bool needs_ssbd_flip(struct vcpu *v) cpu_require_ssbd_mitigation(); } -static void enter_hypervisor_head(struct cpu_user_regs *regs) +/* + * Actions that needs to be done after entering the hypervisor from the + * guest and before we handle any request. + */ +void enter_hypervisor_from_guest(void) { - if ( guest_mode(regs) ) - { - struct vcpu *v = current; + struct vcpu *v = current; - /* If the guest has disabled the workaround, bring it back on. */ - if ( needs_ssbd_flip(v) ) - arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL); + /* If the guest has disabled the workaround, bring it back on. */ + if ( needs_ssbd_flip(v) ) + arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL); - /* - * If we pended a virtual abort, preserve it until it gets cleared. - * See ARM ARM DDI 0487A.j D1.14.3 (Virtual Interrupts) for details, - * but the crucial bit is "On taking a vSError interrupt, HCR_EL2.VSE - * (alias of HCR.VA) is cleared to 0." - */ - if ( v->arch.hcr_el2 & HCR_VA ) - v->arch.hcr_el2 = READ_SYSREG(HCR_EL2); + /* + * If we pended a virtual abort, preserve it until it gets cleared. + * See ARM ARM DDI 0487A.j D1.14.3 (Virtual Interrupts) for details, + * but the crucial bit is "On taking a vSError interrupt, HCR_EL2.VSE + * (alias of HCR.VA) is cleared to 0." + */ + if ( v->arch.hcr_el2 & HCR_VA ) + v->arch.hcr_el2 = READ_SYSREG(HCR_EL2); #ifdef CONFIG_NEW_VGIC - /* - * We need to update the state of our emulated devices using level - * triggered interrupts before syncing back the VGIC state. - * - * TODO: Investigate whether this is necessary to do on every - * trap and how it can be optimised. - */ - vtimer_update_irqs(v); - vcpu_update_evtchn_irq(v); + /* + * We need to update the state of our emulated devices using level + * triggered interrupts before syncing back the VGIC state. + * + * TODO: Investigate whether this is necessary to do on every + * trap and how it can be optimised. + */ + vtimer_update_irqs(v); + vcpu_update_evtchn_irq(v); #endif - vgic_sync_from_lrs(v); - } + vgic_sync_from_lrs(v); } void do_trap_guest_sync(struct cpu_user_regs *regs) { const union hsr hsr = { .bits = regs->hsr }; - enter_hypervisor_head(regs); - switch ( hsr.ec ) { case HSR_EC_WFI_WFE: @@ -2158,8 +2157,6 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs) { const union hsr hsr = { .bits = regs->hsr }; - enter_hypervisor_head(regs); - switch ( hsr.ec ) { #ifdef CONFIG_ARM_64 @@ -2196,27 +2193,21 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs) void do_trap_hyp_serror(struct cpu_user_regs *regs) { - enter_hypervisor_head(regs); - __do_trap_serror(regs, VABORT_GEN_BY_GUEST(regs)); } void do_trap_guest_serror(struct cpu_user_regs *regs) { - enter_hypervisor_head(regs); - __do_trap_serror(regs, true); } void do_trap_irq(struct cpu_user_regs *regs) { - enter_hypervisor_head(regs); gic_interrupt(regs, 0); } void do_trap_fiq(struct cpu_user_regs *regs) { - enter_hypervisor_head(regs); gic_interrupt(regs, 1); } @@ -2259,7 +2250,13 @@ static void check_for_vcpu_work(void) local_irq_disable(); } -void leave_hypervisor_tail(void) +/* + * Actions that needs to be done before entering the guest. This is the + * last thing executed before the guest context is fully restored. + * + * The function will return with IRQ masked. + */ +void leave_hypervisor_to_guest(void) { local_irq_disable(); From patchwork Thu Oct 31 15:09:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178192 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980221ill; Thu, 31 Oct 2019 08:11:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfZfy9qBLqHyRjKEEkuExNg06UaQow+POJgyFi9KClbqQooBlX7MDd2sG3abSGmpkDtiW+ X-Received: by 2002:a5d:9808:: with SMTP id a8mr884724iol.2.1572534679595; Thu, 31 Oct 2019 08:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534679; cv=none; d=google.com; s=arc-20160816; b=ujHCkOIvyXGKUZxDBR3RLz+22dOz9vqCLIF8yVhB+eqpfGlCGItF3MbD3ZQR46Lf4w xUbXHIzucPJS1+NATOs/rFxAE9qIrvUXDsOyUZgj24nu7g+bGFit3IYYSS5uj4gNRiNA VX+ZeVigJP2lhEsS2l3waXDAxq5kKLi2SjBbWxXgOWJjdW0daHKhcoccmuOOkOSM8llS Nct5Jqv3ziTAF1guEV3lPhrsmC0PSSYzPHawtLtSSidESwwL4UKuoz4M4ucnrHAkK7Zs wBqH1E5DlSzlqMvDrdXz5+vsFvgNj0/AOkdQAzEsCnpzKbk072ccxlKLKb/WkL4LfScB FRlQ== 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=c77n/GLT3qijT32dYnb/keZw9W73/TWl6JRwr0iQBAM=; b=qjm1Ml3ZP303ocMLja9adwyTdsh4sydO8c1rJ+xbHZ0cMErG6tmP2fpVmXuVdsRekD oYd1CO5wy6LBrSyd3BHBnelsiFwOQew2SZPHX7+KlzZnyW911NjGeGKnQs9q8GCGFV1i ZH13+6TsO4ntICyhv/d91QTZnMyS7WjuBy25MvYFVFZmVZkvuez/tCu6UH9V5+P0qaui Wwiv9EbEU6M6YRtJRh5FZNz5hRipxuAxsuLYJzzXoe6k6VvI6O3W5SnSOQQKIOUMNfu1 43a/gfP4r4nLcyEdwP04D7JD2bCxI9TXISV1XfhKhbD+VLRiCV9TSbyE2aOAFECCaUQC ImmQ== 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 b15si7264372ilh.56.2019.10.31.08.11.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:19 -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 1iQC5D-0006bI-9c; Thu, 31 Oct 2019 15:09:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC5C-0006ai-Bp for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:54 +0000 X-Inumbo-ID: 795405f0-fbf0-11e9-bbab-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 795405f0-fbf0-11e9-bbab-bc764e2007e4; Thu, 31 Oct 2019 15:09:45 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8CD3A7A7; Thu, 31 Oct 2019 08:09:45 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A11F73F71E; Thu, 31 Oct 2019 08:09:44 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:13 +0000 Message-Id: <20191031150922.22938-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 10/19] xen/arm32: entry: Rename save_guest_regs() 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function save_guest_regs() is doing more than saving guest registers. It also restore the vectors table and consume any pending SErrors generated by the guest. So rename the function to arch_enter_hypervisor_from_guest_preirq(). Take the opportunity to use ENDPROC() for the benefits of static analizer and the reader. Signed-off-by: Julien Grall --- The name of the label is quite long but this was the best I came up. Other suggestions made were guest_vector() and guest_entry(). I think guest_vector() is a no-go because we are only implementing part of the vector. Regarding guest_entry(), this is debatable because from the guest PoV, you exit it so it can be misleading. I actually got confused more than one time. Another possibility would be enter_from_guest(), but this is fairly close to enter_hypervisor_from_guest(). The code would look like: bl enter_from_guest csie ... bl enter_hypervisor_from_guest Any other suggestion for the name? Changes in v3: - Patch added --- xen/arch/arm/arm32/entry.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 5abff24e91..cea4e0e302 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -24,7 +24,11 @@ #define RESTORE_BANKED(mode) \ RESTORE_ONE_BANKED(SP_##mode) ; RESTORE_ONE_BANKED(LR_##mode) ; RESTORE_ONE_BANKED(SPSR_##mode) -save_guest_regs: +/* + * Actions that needs to be done after entering the hypervisor from the + * guest and before the interrupts are unmasked. + */ +arch_enter_hypervisor_from_guest_preirq: #ifdef CONFIG_ARM32_HARDEN_BRANCH_PREDICTOR /* * Restore vectors table to the default as it may have been @@ -115,6 +119,7 @@ abort_guest_exit_end: skip_check: mov pc, lr +ENDPROC(arch_enter_hypervisor_from_guest_preirq) /* * Macro to define a trap entry. @@ -173,7 +178,7 @@ skip_check: 1: /* Trap from the guest */ - bl save_guest_regs + bl arch_enter_hypervisor_from_guest_preirq .if \guest_iflags != n cpsie \guest_iflags .endif @@ -363,7 +368,7 @@ return_to_hypervisor: * HVBAR very late. * * Default vectors table will be restored on exit (see - * save_guest_regs). + * arch_enter_hypervisor_from_guest_preirq). */ mov r9, #0 /* vector tables = NULL */ /* From patchwork Thu Oct 31 15:09:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178185 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2979959ill; Thu, 31 Oct 2019 08:11:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKk71+OqS7qfTrG0dlL5X7fZ4BWonc51fOTUka4aJPMtePyneKGWg29gLDhj+vfAChEjRQ X-Received: by 2002:a5d:8d8f:: with SMTP id b15mr5581953ioj.296.1572534669244; Thu, 31 Oct 2019 08:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534669; cv=none; d=google.com; s=arc-20160816; b=QZmsXVuo8pQnGPAGG0CtjH0iaLskgVJKAJQnaWiQaPCAdPkgz1tVjCZ6EKKTbDgjcz KTYqkixhOBGwDkmiU/G4LMBrQiigMSjGQ583kgORbSC99yZ6uDEjpTRUGBcHd2PN/a+t SMxIGf6NvnYLKPYN/Riwc7hrMmkiXa5VwBSLLkZ1Wf1z9DvMgUxaYGBz3ZKqphg4HAvI p0Bbr52KVca/Tf4NUesgw7t0i6UkAQ1mw/BgrLBkSQy+Ic7t5hcfAdzYQZSDxhXQ0Nuh MR3zUT9D6NVRO0x2DTITSITSZ0VX19haRLHfWbSm//rLlRGryLaibgndS9Eg1xN06iBV WQ7Q== 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=canYzUswTxCqzX7IzItdxlbAqFqYQ/Z/KFNdEZJYz14=; b=te770h6CY3stMeRw5W1BBoU0o6lkZbBDaKx5mn2bbuEE6RMCcFb8HzdWPh0dHNyDkH 1xtYJZZJoRpxqKoquah4a964sn+YGtYOw4JMVOPZd66KQZ9b89MECrG6H6v787KeGLfz K0XDDegayyeZB5WQ1ZuCBplY57XEeOu2ot1vWDKpUsDgI3FJYKILUVEd18zzXHuNlUS6 DmftDr73iC0sqgWp0CWGwyKe7rT7InVv0kgpjYLK/xcHOSvxfkm0fCOkNAEl2qmMFGxv kvoM+U6nQ2VRCPa1AICR5GMAkZ6vGTCjyCLZE7SjkZUWPQs72icxHGbks61eJxfaezW+ xtJQ== 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 z3si8077642ilq.18.2019.10.31.08.11.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:09 -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 1iQC5P-00075m-6f; Thu, 31 Oct 2019 15:10:07 +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 1iQC5N-0006wm-BW for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:05 +0000 X-Inumbo-ID: 7a01744c-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7a01744c-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:46 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8C5068D; Thu, 31 Oct 2019 08:09:46 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C13723F71E; Thu, 31 Oct 2019 08:09:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:14 +0000 Message-Id: <20191031150922.22938-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 11/19] xen/arm: Ensure the SSBD workaround is re-enabled right after exiting a guest 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Julien Grall , Andrii Anisov , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, SSBD workaround is re-enabled for Xen after interrupts are unmasked. This means we may end up to execute some part of the hypervisor if an interrupt is received before the workaround is re-enabled. Each trap may require to unmask different interrupts. As the rest of enter_hypervisor_from_guest() does not require to have interrupts masked, the function is now split in two parts: 1) enter_hypervisor_from_guest_preirq() called with interrupts masked. 2) enter_hypervisor_from_guest() called with interrupts unmasked. Note that while it might be possible to avoid spliting the function in two parts, it requires a bit more work than I can currently invest to avoid using indirect branch. Furthermore, the function name is rather generic as there might be more work to dob before interrupts are unmasked in the future. Fixes: a7898e4c59 ("xen/arm: Add ARCH_WORKAROUND_2 support for guests") Reported-by: Andrii Anisov Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v4: - Remove spurious line Changes in v3: - Rework the arm32 part Changes in v2: - Add Arm32 code - Rename enter_hypervisor_from_guest_noirq() to enter_hypervisor_from_guest_preirq() - Update the commit message to explain the choice of splitting the code. --- xen/arch/arm/arm32/entry.S | 2 +- xen/arch/arm/arm64/entry.S | 1 + xen/arch/arm/traps.c | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index cea4e0e302..0a9c248ee2 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -118,7 +118,7 @@ abort_guest_exit_end: bne return_from_trap skip_check: - mov pc, lr + b enter_hypervisor_from_guest_preirq ENDPROC(arch_enter_hypervisor_from_guest_preirq) /* diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 97dc60210d..d4fb5fdc1c 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -191,6 +191,7 @@ ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", "nop; nop", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) + bl enter_hypervisor_from_guest_preirq msr daifclr, \iflags bl enter_hypervisor_from_guest mov x0, sp diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index adbedc2d15..cb4e3b627b 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1986,15 +1986,25 @@ static inline bool needs_ssbd_flip(struct vcpu *v) /* * Actions that needs to be done after entering the hypervisor from the - * guest and before we handle any request. + * guest and before the interrupts are unmasked. */ -void enter_hypervisor_from_guest(void) +void enter_hypervisor_from_guest_preirq(void) { struct vcpu *v = current; /* If the guest has disabled the workaround, bring it back on. */ if ( needs_ssbd_flip(v) ) arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL); +} + +/* + * Actions that needs to be done after entering the hypervisor from the + * guest and before we handle any request. Depending on the exception trap, + * this may be called with interrupts unmasked. + */ +void enter_hypervisor_from_guest(void) +{ + struct vcpu *v = current; /* * If we pended a virtual abort, preserve it until it gets cleared. From patchwork Thu Oct 31 15:09:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178203 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980573ill; Thu, 31 Oct 2019 08:11:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjVD2+tVyCzq9mOV9x7qBO5MejbIb4VAJLI1WdL8HpcRAyEIOmucaeQ3vuwNNnkBAHzRh3 X-Received: by 2002:a92:5d8d:: with SMTP id e13mr6832888ilg.32.1572534695319; Thu, 31 Oct 2019 08:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534695; cv=none; d=google.com; s=arc-20160816; b=lVgP5OarwLZpJtvvduQ7G1zBppUFBI8D0wz5uP3EHHX72Ex4+u+/QZuQz5Vv54m0gb GmeYkeIEaNCnkOxODW8c8Ba7BZAZXe5bYxyouEla3G5QJemaNBvr3+QKIn7XleBcSGo6 56bNyAl5FYtNe3YTR0Qf2Fy3Bbb5rJ7bU31fcQam077UcxAI+UYh/rmOVjqBKx/dwan3 kA+sAwdxH0eJjmpSUF2Rbr3M9e4kW58N3VbiknytMSgERUWujspir88PBfRv9YJ4flj0 LFLgqTJv6rnlwMo4O0ePrOsc4jTTsoKsVxGtVapKVY8nqwHPzTHYPtI+a2WFXsV0AXyF pupA== 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=fJVjdsJTVqVVDY435vCdCro4LAz3EELP/VXIlZcXwJg=; b=rPzYnoMlClnT/kXFH1GKiBPdWNYuaSS7Z0ve92e3aqc668SSxVHEZeZeB3UX47m63q sH8uocW1gkda5EpgVJQAnvv35zS1uMxWRY0smbkgasLUFA3vdK0VkVguJp31O3bDzpUJ G2aS6Uaq6KU1lStUnAqUDl5jnrCaeLVCKvkQR2eWod+nOa1XwWwuH8kpI8Z2J6DPhmi4 LAbFV54AVHOi0QJukwA/xUARMPyWBa9WaBbDbjrFEfbCFRCxOZ8abMfMHlpT289wwbYt TbKWBFxzGcK74qc82XK/GTLW4Eo7ELOTYgW+n94QMP4cBe6z1Fdy2AhfoYmZ1lxQmSQu i1fw== 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 h18si7097122iog.106.2019.10.31.08.11.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:35 -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 1iQC5T-0007Ow-V1; Thu, 31 Oct 2019 15:10:11 +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 1iQC5S-0007N3-BX for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:10 +0000 X-Inumbo-ID: 7ac3ffc6-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7ac3ffc6-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:48 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E95CE4F5; Thu, 31 Oct 2019 08:09:47 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09E493F71E; Thu, 31 Oct 2019 08:09:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:15 +0000 Message-Id: <20191031150922.22938-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 12/19] xen/arm: traps: Don't ignore invalid value for serrors= 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" serrors= only supports 3 values "diverse", "forward" and "panic". The current implementation of parse_serrors_behavior() will default to "diverse" for any invalid value and not tell the users. Rather than ignore the invalid input, return an error to the caller so it can decides the be approach. This will be useful after a follow-up patch where the number of options will be reduced. Take the opportunity to initialize serrors_op to SERRORS_DIVERSE rather than relying on the item to be the first in the enum and therefore equal to 0. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellin --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Patch added --- xen/arch/arm/traps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index cb4e3b627b..d028ec9224 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -104,14 +104,16 @@ register_t get_default_hcr_flags(void) static enum { SERRORS_DIVERSE, SERRORS_PANIC, -} serrors_op; +} serrors_op = SERRORS_DIVERSE; static int __init parse_serrors_behavior(const char *str) { if ( !strcmp(str, "panic") ) serrors_op = SERRORS_PANIC; - else + else if ( !strcmp(str, "diverse") ) serrors_op = SERRORS_DIVERSE; + else + return -EINVAL; return 0; } From patchwork Thu Oct 31 15:09:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178189 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980124ill; Thu, 31 Oct 2019 08:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwh4uJglYO9FBTToZCCkjS/V6jFpJk4AwUsrt9Ykna3XpVgdj8KIxZR3hiP/2eG39q2lmSd X-Received: by 2002:a02:9521:: with SMTP id y30mr3811313jah.107.1572534675871; Thu, 31 Oct 2019 08:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534675; cv=none; d=google.com; s=arc-20160816; b=ue80NTJ8aIaIC3ZDtSIFex9kN+gadxVOL60yulxSC0P7qN8949R9yErsVkIlX4JIyd HprSht5hbq/VvZRHGy4fCQSVQfuK+TeXDZbuUCe3Et/lEvCXaZRovhoSOx/8vrWPMKxA UD/3MKll5eNzcxX3GSOgdRZuQqLBqyXuE3TKuGMx3uZVU+rg65xNN6EpCaWCTV4xTm+w NsDNmGsiv/dW7YXnxZTALXoLAzcPfF5+1mC2JrDt6hcP0F/AHkUCg2yL3DUenl0wDEm7 q6bG5ne+hUMIb2cVbuxDz+jMVASMkvN65YHU12KoB+5IbgaCWKhMxtsBZ2gpNtoJEivb XDTg== 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=Jf3Ezr1okHhFMtckpYGBqSJNa2EXSFC/cvYeTala+bg=; b=uz7Cba6NnxpN5S0Snw3x3+G+rT7Cc1AhHfXWGGFupnm7B0GHsIc6/FnNspAuwCs5Tq //RoRAMT7oj3scNoKo2t+6UUHusppVOvIHayhbdInSn9U46gJKuo/es9wnqtP7v/hpP6 r8FMkuZLHyrW3+T515H+FH0oLm3Mk4xlc/zo09/BY8PPlTdaSXgh5pkRcc901WZbFti4 oVGL7sp6nJ0wUYmadkH/BqtJzo9GSqFDDrWcrsfi4jMba3fUKtJB4Wn6Ura4ppI2B1xT bj4Bq6PBThUImFNFRQolTmof3a6MS26C8wRmP03w+kBn706YrK2ri++GjKXySKt+s27k KUcg== 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 d78si7938467ild.23.2019.10.31.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:15 -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 1iQC5Y-0007Y2-K2; Thu, 31 Oct 2019 15:10:16 +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 1iQC5X-0007Wu-Am for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:15 +0000 X-Inumbo-ID: 7b1b11f0-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7b1b11f0-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:49 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F9D468D; Thu, 31 Oct 2019 08:09:49 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A8BE3F71E; Thu, 31 Oct 2019 08:09:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:16 +0000 Message-Id: <20191031150922.22938-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 13/19] xen/arm: alternative: Remove unused parameter for alternative_if_not_cap 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Julien Grall , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The macro alternative_if_not_cap is taking two parameters. The second parameter is never used and it is hard to see how this can be used correctly as it is only protecting the alternative section magic. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Acked-by: Stefano Stabellini --- Changes in v2: - Add Volodymyr's reviewed-by - Add Stefano's acked-by --- xen/include/asm-arm/alternative.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xen/include/asm-arm/alternative.h b/xen/include/asm-arm/alternative.h index dedb6dd001..2830a6da2d 100644 --- a/xen/include/asm-arm/alternative.h +++ b/xen/include/asm-arm/alternative.h @@ -116,13 +116,11 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en * The code that follows this macro will be assembled and linked as * normal. There are no restrictions on this code. */ -.macro alternative_if_not cap, enable = 1 - .if \enable +.macro alternative_if_not cap .pushsection .altinstructions, "a" altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f .popsection 661: - .endif .endm /* From patchwork Thu Oct 31 15:09:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178193 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980246ill; Thu, 31 Oct 2019 08:11:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCUxbObPrTAZIFofBc+HM+uMa19zmK0ckLyft+e3m4I1qRjfLbP16n9W9ld+8OMFxk1YUf X-Received: by 2002:a05:6602:1cc:: with SMTP id w12mr5874378iot.133.1572534681184; Thu, 31 Oct 2019 08:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534681; cv=none; d=google.com; s=arc-20160816; b=BhFMOSVEXywgwUibBzx//6MmGshv0Ob91A9rUi7OFYf/GZJfj05nDTA4P7Rm/3BkJh ZiiBsj57G3yjdm4gCB80ZUvBBr3aIP32l6Y5poAlyFk8T4RzAyeK//4na2BBGtZ7qP7v uOjqSbIRLgV+s1e0v31k3133eDHBEeCrkB2EKSs1bBiOyE97AHQOfcTX8sl5BdW73fsx cdKzTaAYAevWCIzA1+yCCRMHxxH0MFvhdIIPTZ3T25YFZa52HUrx19OzeEhsRlTTlgX7 /ewJWyFqPWOXiVrYMWDCUw0PfbUA8H5juqFNPnbduqprppM69NVClnX9xcIc7/T8CVo6 p5cw== 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=maQt4+Rk+LxVkDdVWYTA1t4P2OA3YnEIn0xCqM8D6EE=; b=hX8YPotrrqFOjE9msRuR13/FFPVOUqE85R64eghBZ3wTuY5PsWQZM0S+qPliuIX98Q Eo60bOqzgQzZ5RPnQvJJREBOVNNz/mcbNAFhaBjHEjP/K/1i5ACeuNdB0gh358BMNaDD OO1r3PLXcOZPM6P6quAy9IuMNoMIZShWmj7I0TEXvYA6EPuHxtHIQ3jPreDvvahQxXlS AsPbsKjvxhGD2ijBdbWh/oI+wFzYRjEuAf9j4Ni1p+m3ELmAeHOneXL0Ui4hCozMjxnQ YsgmZhDEVocYYg6l4noAPic3u+bsTlUCkbDAIRntY45Wspv4p7t5r73x8UTt9VMVyFxI qMBQ== 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 d3si7840080jab.22.2019.10.31.08.11.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:21 -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 1iQC5c-0007cy-VV; Thu, 31 Oct 2019 15:10:20 +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 1iQC5c-0007cL-BL for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:20 +0000 X-Inumbo-ID: 7c48a022-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7c48a022-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:50 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E2457A7; Thu, 31 Oct 2019 08:09:50 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 652183F71E; Thu, 31 Oct 2019 08:09:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:17 +0000 Message-Id: <20191031150922.22938-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 14/19] xen/arm: Move ARCH_PATCH_INSN_SIZE out of the header livepatch.h 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: jgross@suse.com, Stefano Stabellini , Julien Grall , Konrad Rzeszutek Wilk , Ross Lagerwall , Julien Grall , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, ARCH_PATCH_INSN_SIZE is defined in the header livepatch.h. However, this is also used in the alternative code. Rather than including livepatch.h just for using the define, move it in the header insn.h which seems more suitable. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Reviewed-by: Ross Lagerwall Acked-by: Stefano Stabellini --- Changes in v2: - Add Ross's reviewed-by - Add Stefano's acked-by - Add Volodymyr's reviewed-by --- xen/arch/arm/alternative.c | 2 -- xen/include/asm-arm/insn.h | 3 +++ xen/include/asm-arm/livepatch.h | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c index 52ed7edf69..237c4e5642 100644 --- a/xen/arch/arm/alternative.c +++ b/xen/arch/arm/alternative.c @@ -30,8 +30,6 @@ #include #include #include -/* XXX: Move ARCH_PATCH_INSN_SIZE out of livepatch.h */ -#include #include /* Override macros from asm/page.h to make them work with mfn_t */ diff --git a/xen/include/asm-arm/insn.h b/xen/include/asm-arm/insn.h index 3489179826..19277212e1 100644 --- a/xen/include/asm-arm/insn.h +++ b/xen/include/asm-arm/insn.h @@ -11,6 +11,9 @@ # error "unknown ARM variant" #endif +/* On ARM32,64 instructions are always 4 bytes long. */ +#define ARCH_PATCH_INSN_SIZE 4 + #endif /* !__ARCH_ARM_INSN */ /* * Local variables: diff --git a/xen/include/asm-arm/livepatch.h b/xen/include/asm-arm/livepatch.h index 6bca79deb9..026af5e7dc 100644 --- a/xen/include/asm-arm/livepatch.h +++ b/xen/include/asm-arm/livepatch.h @@ -7,9 +7,7 @@ #define __XEN_ARM_LIVEPATCH_H__ #include /* For SZ_* macros. */ - -/* On ARM32,64 instructions are always 4 bytes long. */ -#define ARCH_PATCH_INSN_SIZE 4 +#include /* * The va of the hypervisor .text region. We need this as the From patchwork Thu Oct 31 15:09:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178195 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980321ill; Thu, 31 Oct 2019 08:11:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlEBNbFOJpnlTj5WlP27p2bs83uWlMmFT505KYqf3/xtpTV0EYkVsoejB5tiKG4zqbbZZq X-Received: by 2002:a6b:d104:: with SMTP id l4mr5652034iob.50.1572534683905; Thu, 31 Oct 2019 08:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534683; cv=none; d=google.com; s=arc-20160816; b=SZoGUQ8lvcv37XwFroI24hQkiArFLcH96Vyaz8QTDS4j8OMzjuqqruD7iJt0REhrft YUA7j3ylwUU5X7FaO6SvNvics+t1IfFDoeFgTTvQX1xl4btfXOQA0LbR7v/wB0tpDkXt 4LK8yW+gXBbDcCGEC2rx53bQ05KJXEtL91ImAJ9UD9Uqpy6HneV2+SLPuotUfssdvsOj 1c+TtKEa8tsw1S8MvRkBGsNNI8g6KTlgE9HrO03PKbuPJGwVNCS+UA4Xfk0mTtLYoYxN CR0iRGM5U14pCnU6fI3OhcffGDmskwFZRxOkDrfl+GNcFn2QSBcYqOcWQBsV/oRCVmgl CGjQ== 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=hxxajyU30rVPA4aBN2hqxvTU1b1t7CFTWTb4BlVB1yA=; b=i1xqke9Ilv9kQGsOqo0f0586v5KON74bK1LIXenG141W297PanTm1liFV36Y6t17dI 8EBY8cMA+OsS/7KXQQjiLEXjIW1hXlWD5FuXc47J/kBOcJpRnLqW8wMulhPIUFvpMTkM 5/9DfWi/w8A+YdBCL0rhnXCjjLZ3J4yUnEA1/QTYfVUaadJPqLEFL+0it9nVQ0iCkNwd RzTMRflBUIyFCkO1W6maDPe+nb/suLBHX9bUpUFruNHkH+whh727vYr0Hb23JZfLGTHK oT+DQVea4Bt5zOrKDVZ9xm0l+vNoJlcpaMbRetGg3ebMsAPQsWJ7x4pJ9z6gioLd3D3O IJLw== 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 l29si9200152jap.83.2019.10.31.08.11.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:23 -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 1iQC5J-0006h5-5F; Thu, 31 Oct 2019 15:10:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC5H-0006fZ-CW for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:09:59 +0000 X-Inumbo-ID: 7cf7f202-fbf0-11e9-bbab-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 7cf7f202-fbf0-11e9-bbab-bc764e2007e4; Thu, 31 Oct 2019 15:09:51 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B9C107B9; Thu, 31 Oct 2019 08:09:51 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D204D3F71E; Thu, 31 Oct 2019 08:09:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:18 +0000 Message-Id: <20191031150922.22938-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 15/19] xen/arm: Allow insn.h to be called from assembly 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A follow-up patch will require to include insn.h from assembly code. So we need to protect any C-specific definition to avoid compilation errors when used in assembly code. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Fix typo - Remove in-code comment --- xen/include/asm-arm/insn.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/include/asm-arm/insn.h b/xen/include/asm-arm/insn.h index 19277212e1..27271e95f9 100644 --- a/xen/include/asm-arm/insn.h +++ b/xen/include/asm-arm/insn.h @@ -1,6 +1,8 @@ #ifndef __ARCH_ARM_INSN #define __ARCH_ARM_INSN +#ifndef __ASSEMBLY__ + #include #if defined(CONFIG_ARM_64) @@ -11,6 +13,8 @@ # error "unknown ARM variant" #endif +#endif /* __ASSEMBLY__ */ + /* On ARM32,64 instructions are always 4 bytes long. */ #define ARCH_PATCH_INSN_SIZE 4 From patchwork Thu Oct 31 15:09:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178202 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980545ill; Thu, 31 Oct 2019 08:11:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqze/ywEf474uM/iohY8p82EaxbFoHV23EP5oDURpg7EGA/UsDkadScd1nGGia/SMt5Fy1xM X-Received: by 2002:a92:d5cf:: with SMTP id d15mr6625088ilq.302.1572534694409; Thu, 31 Oct 2019 08:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534694; cv=none; d=google.com; s=arc-20160816; b=bXoiAiEvDvEXIO6LtMWh9um4fZ2grXl/FxwEcr/hzMIPkkddp6Ie0ntJ+pR9R/TwOB iIbB3AiVpvRlaJ1YOvZKgzzEJczgqnUcom6uXz9FIyRsEPGPhwSUBd677eIGWMQP+3WQ oASI+eeaJ+Z+KW0Nr7dPnwIlY9KrXYVn+u+gWAfw0SeW9qo76fDNrb5k4a4NV9idgQMf tCWe1A+QvcKmJKtLOfwLfbAke906lfAOsqxlVS6xHXI6gwFNkWplge5Zc+35Xur4B3EQ QHJxGIrinqwtjIMV0xxZnquPFqgaWSSZP06+73R39ZouJKr9jqysMC2nyQnFkvXJYbtG ZBaA== 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=aMhnsgXwzJ3sB8Mo3AhmPHKRjTBiyF126MxaZ8TX0Mw=; b=tl+JdYnl4ylQknRFWmGb+mFzXAcu7DZ92FyieP0nBgoa+DEr/l0y5525fTfJrMzZuP D37Tm5qhbTe1SikBFFPD+/2tftJ/011yA7r2LcDMeQspFEbDsxzdmCBn/veRBaQMwFuv OxgYsXl4sXwKegvvXXzLTY2XJo7xhRNBXbrhRagQO1QvA4L1wYYJv6dHNVFzMWXv+pWj 9V/1Th+vfPnM9fRLlOFhynHbRiHXoTXqdEO2AAVB6z0e/pu/7E8yLhyJqMGwYcOn58AU lNji67vNztN6I/OHhsUKFKKQs5+LXa9boigoSou0bDDnAvWig/uCdUvzWWrHjsXfYSGO pX1g== 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 h9si7551969ilq.118.2019.10.31.08.11.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:34 -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 1iQC5N-0006xK-U1; Thu, 31 Oct 2019 15:10:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC5M-0006wA-Bo for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:04 +0000 X-Inumbo-ID: 7de919de-fbf0-11e9-a531-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 7de919de-fbf0-11e9-a531-bc764e2007e4; Thu, 31 Oct 2019 15:09:53 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 38BAA7CD; Thu, 31 Oct 2019 08:09:53 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF0283F71E; Thu, 31 Oct 2019 08:09:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:19 +0000 Message-Id: <20191031150922.22938-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 16/19] xen/arm: alternative: add auto-nop infrastructure 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: jgross@suse.com, Mark Rutland , Stefano Stabellini , Julien Grall , Will Deacon , Julien Grall , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Mark Rutland In some cases, one side of an alternative sequence is simply a number of NOPs used to balance the other side. Keeping track of this manually is tedious, and the presence of large chains of NOPs makes the code more painful to read than necessary. To ameliorate matters, this patch adds a new alternative_else_nop_endif, which automatically balances an alternative sequence with a trivial NOP sled. In many cases, we would like a NOP-sled in the default case, and instructions patched in in the presence of a feature. To enable the NOPs to be generated automatically for this case, this patch also adds a new alternative_if, and updates alternative_else and alternative_endif to work with either alternative_if or alternative_endif. The alternative infrastructure was originally ported from Linux. So this is pretty much a straight backport from commit 792d47379f4d "arm64: alternative: add auto-nop infrastructure". The only difference is the nops macro added as not yet existing in Xen. Signed-off-by: Mark Rutland [will: use new nops macro to generate nop sequences] Signed-off-by: Will Deacon [julien: Add nops and port to Xen] Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Acked-by: Stefano Stabellini --- Changes in v3: - Add missing include to get auto-nop infrastructure build on arm32. Changes in v2: - Add Volodymyr's reviewed-by - Add Stefano's acked-by --- xen/include/asm-arm/alternative.h | 71 +++++++++++++++++++++++++++++---------- xen/include/asm-arm/macros.h | 7 ++++ 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/xen/include/asm-arm/alternative.h b/xen/include/asm-arm/alternative.h index 2830a6da2d..92e888aff8 100644 --- a/xen/include/asm-arm/alternative.h +++ b/xen/include/asm-arm/alternative.h @@ -2,6 +2,7 @@ #define __ASM_ALTERNATIVE_H #include +#include #define ARM_CB_PATCH ARM_NCAPS @@ -87,6 +88,7 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en #else #include +#include .macro altinstruction_entry orig_offset alt_offset feature orig_len alt_len .word \orig_offset - . @@ -111,34 +113,55 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en .endm /* - * Begin an alternative code sequence. + * Alternative sequences + * + * The code for the case where the capability is not present will be + * assembled and linked as normal. There are no restrictions on this + * code. + * + * The code for the case where the capability is present will be + * assembled into a special section to be used for dynamic patching. + * Code for that case must: + * + * 1. Be exactly the same length (in bytes) as the default code + * sequence. * - * The code that follows this macro will be assembled and linked as - * normal. There are no restrictions on this code. + * 2. Not contain a branch target that is used outside of the + * alternative sequence it is defined in (branches into an + * alternative sequence are not fixed up). + */ + +/* + * Begin an alternative code sequence. */ .macro alternative_if_not cap + .set .Lasm_alt_mode, 0 .pushsection .altinstructions, "a" altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f .popsection 661: .endm +.macro alternative_if cap + .set .Lasm_alt_mode, 1 + .pushsection .altinstructions, "a" + altinstruction_entry 663f, 661f, \cap, 664f-663f, 662f-661f + .popsection + .pushsection .altinstr_replacement, "ax" + .align 2 /* So GAS knows label 661 is suitably aligned */ +661: +.endm + /* - * Provide the alternative code sequence. - * - * The code that follows this macro is assembled into a special - * section to be used for dynamic patching. Code that follows this - * macro must: - * - * 1. Be exactly the same length (in bytes) as the default code - * sequence. - * - * 2. Not contain a branch target that is used outside of the - * alternative sequence it is defined in (branches into an - * alternative sequence are not fixed up). + * Provide the other half of the alternative code sequence. */ .macro alternative_else -662: .pushsection .altinstr_replacement, "ax" +662: + .if .Lasm_alt_mode==0 + .pushsection .altinstr_replacement, "ax" + .else + .popsection + .endif 663: .endm @@ -154,12 +177,26 @@ int apply_alternatives(const struct alt_instr *start, const struct alt_instr *en * Complete an alternative code sequence. */ .macro alternative_endif -664: .popsection +664: + .if .Lasm_alt_mode==0 + .popsection + .endif .org . - (664b-663b) + (662b-661b) .org . - (662b-661b) + (664b-663b) .endm /* + * Provides a trivial alternative or default sequence consisting solely + * of NOPs. The number of NOPs is chosen automatically to match the + * previous case. + */ +.macro alternative_else_nop_endif +alternative_else + nops (662b-661b) / ARCH_PATCH_INSN_SIZE +alternative_endif +.endm + +/* * Callback-based alternative epilogue */ .macro alternative_cb_end diff --git a/xen/include/asm-arm/macros.h b/xen/include/asm-arm/macros.h index 1d4bb41d15..91ea3505e4 100644 --- a/xen/include/asm-arm/macros.h +++ b/xen/include/asm-arm/macros.h @@ -13,4 +13,11 @@ # error "unknown ARM variant" #endif + /* NOP sequence */ + .macro nops, num + .rept \num + nop + .endr + .endm + #endif /* __ASM_ARM_MACROS_H */ From patchwork Thu Oct 31 15:09:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178201 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980517ill; Thu, 31 Oct 2019 08:11:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLNicv+o29IZ8zzQDkuUgECRggDQPMubNJ5gSIM9o99eoLC+JLeuQ2XNbeQGPG55iIyIaU X-Received: by 2002:a6b:f40f:: with SMTP id i15mr5396994iog.54.1572534693125; Thu, 31 Oct 2019 08:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534693; cv=none; d=google.com; s=arc-20160816; b=yoGXTHAQtSbgzerLqTD0lArGh8LMK/fkksVA+D9HJvDhzazjO2yCCDBZP+YKC4iNTU Ea9WYUwx4oolN3vKAEAu1l0i51GR5oYo25tGESePN/WpDakQYM8NGPGMiHAqivB+E9iz OSGJRZezGpy7wI+eQDRy1UIbcqqnvlIEwREU9DAI3hpfvARJSUR/PTnw5Ll8+SIzjxn2 PkqMTsLsaQc95lQWyNngGvdIzvDT0ewdPzVx5Q0P5ZNFX/lEdFRXIuGZSsIlbcpKLQi9 oZkuXR1xZAOZDUpUPNyFbNeonb1PNFzb4lYiTYd8EmRn+vpR+LtQ2VqWTHJJWDcSw/rj zLpg== 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=2UyzX+76bJhBsQY0fJNPZtAbE0R8LAePnLKpglJFgXY=; b=q5fEuME+9XcBGzPd2W9GR7UU7TaW81V4Iz5W9HTCa/BG7q3j8nFt9W4kcNNjDstgwY 1P925pMh9F1Fko62GNemoDYPKOOgvSewKVV9WnPmTinbowT8XfrmNiEMtkrQGNicVClQ DbdXUXz/nDzhMjmWl57HhyisP8/eEkp0ItE9IcSN9t/4zqcUW4h2Mas3desgjeGw4Aju soSyj7XCNWF2Ph594/LrlckyH+ruHpL0DAFMbDTGcqbwLeyEwoKERDUbB/ihR6a2H4I/ 17sdXBZ3T+sWoiALnzlEa1VFvOGJPrtzkMW30YPUNCO3WKs0iTxb13qQtiI05GQ5tHPb e6HQ== 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 y8si9612055jan.59.2019.10.31.08.11.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:33 -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 1iQC5S-0007NR-KA; Thu, 31 Oct 2019 15:10:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iQC5R-0007J5-Cf for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:09 +0000 X-Inumbo-ID: 7e826990-fbf0-11e9-beca-bc764e2007e4 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 7e826990-fbf0-11e9-beca-bc764e2007e4; Thu, 31 Oct 2019 15:09:54 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5CA497FA; Thu, 31 Oct 2019 08:09:54 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E66A3F71E; Thu, 31 Oct 2019 08:09:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:20 +0000 Message-Id: <20191031150922.22938-18-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 17/19] xen/arm: asm: Replace use of ALTERNATIVE with alternative_if 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Using alternative_if makes the code a bit more streamlined. Take the opportunity to use the new auto-nop infrastructure to avoid counting the number of nop in the else part for arch/arm/arm64/entry.S Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- This is pretty much a matter of taste, but at least for arm64 this allows us to use the auto-nop infrastructure. So the arm32 is more to keep inline with arm64. Changes in v4: - Add Stefano's reviewed-by Changes in v3: - Fix build on Arm32 Changes in v2: - Correctly use alternative_if{, _not} --- xen/arch/arm/arm32/entry.S | 7 ++++--- xen/arch/arm/arm64/entry.S | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 0a9c248ee2..34156c4404 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -59,9 +59,10 @@ arch_enter_hypervisor_from_guest_preirq: * If the SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT has been set in the cpu * feature, the checking of pending SErrors will be skipped. */ - ALTERNATIVE("nop", - "b skip_check", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) + alternative_if SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + b skip_check + alternative_else_nop_endif + /* * Start to check pending virtual abort in the gap of Guest -> HYP * world switch. diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index d4fb5fdc1c..a8ba7ab961 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -188,9 +188,11 @@ * is not set. If a vSError took place, the initial exception will be * skipped. Exit ASAP */ - ALTERNATIVE("bl check_pending_vserror; cbnz x0, 1f", - "nop; nop", - SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT) + alternative_if_not SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + bl check_pending_vserror + cbnz x0, 1f + alternative_else_nop_endif + bl enter_hypervisor_from_guest_preirq msr daifclr, \iflags bl enter_hypervisor_from_guest From patchwork Thu Oct 31 15:09:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178200 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980482ill; Thu, 31 Oct 2019 08:11:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1xFhAUo3F5tIaT1yoWDuZBUBB1qAKrwjHiENSB5aZ/zcbb54Kf2x5adfv8M+LOAb+FdVG X-Received: by 2002:a92:46d9:: with SMTP id d86mr6308192ilk.253.1572534691051; Thu, 31 Oct 2019 08:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534691; cv=none; d=google.com; s=arc-20160816; b=kx/YfDe7lB3OidG/RfEANhPcoHp/64e43sIQoGWNZbZDC7QZDRDaSDzDSeUzUVC+J+ ZMh+NWaQrmWNteycJekPLEdWSXzToZUzflRduJi3v87XcO/bSG05i8AonDzWvlMgsm5O X0cmQob/fVRT/PpwWNL2ykAimBFzpBrEMRvJEo/3fDNR6qm4j2zMd/jt/sbN2O+5Hal9 Hx/GOUONEhg0wjwKOHcV64c+rx8T1sVUtQ2ff7Utiv9GBOV4DOFs+oFB8n37h9BIswWK u2xlWatJimVWLAvye35S9RYQarO0DVYkN99BR62kB2xfjxAAjcbcB6ZSYqyFZAjETcC+ /DtQ== 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=iTWkhzbTtgbyuyN9jrHHWTsSuwuvyelhG6KN7HFCEZ0=; b=ap1Vp6LMu3Wb6tKuoa+rgNr3YBUE4KcUTRtgNMlJMF4e/06UOXFm2mcrliv1Aoyae5 K49/oNKm4FQUwDizwnU3v+9g7yVZi+mniVBsVTXAyYJ0Ly9pW5vIBQyzxgjezgwpzALy 58A38B75bcTVSogFGDQSd7aViA7CFxyJHDy+MxqQ2LHVkN3+h+9EdlK6kFpNxQKhAi1n /B/tpbWYOnOL4EhynYEfC9Rw8oilS3gnGEyL2F4VFtfDjK5ihHTEFXfa2jlznDjY0dKW FQmezdEDmjBGFHdvW+VVLwUfdJllV+nYsBQ63ir4mepEYAxwnuGOlFjcpiAEgRzlKfqR tvVg== 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 q3si7774424ilb.65.2019.10.31.08.11.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:31 -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 1iQC5s-0007rg-CC; Thu, 31 Oct 2019 15:10:36 +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 1iQC5r-0007qc-BV for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:35 +0000 X-Inumbo-ID: 7e9ba055-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7e9ba055-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:55 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7BE5F8E6; Thu, 31 Oct 2019 08:09:55 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 922DB3F71E; Thu, 31 Oct 2019 08:09:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:21 +0000 Message-Id: <20191031150922.22938-19-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 18/19] xen/arm: Update the ASSERT() in SYNCHRONIZE_SERROR() 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The macro SYNCHRONIZE_SERROR() has an assert to check whether it will be called with Abort interrupt unmasked. However, this is only done if a given cap is not enabled. None of the callers will treat the abort interrupt differently depending on a feature. Furthermore, it makes more difficult to check whether SYNCHRONIZE_SERROR() is going to be called with abort interrupt unmasked. Therefore, we now require the abort interrupt to be unmasked regardless the state of the cap. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v3: - Add Stefano's acked-by Changes in v2: - Patch added --- xen/include/asm-arm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index e9d2ae2715..aa642e3ab2 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -542,7 +542,7 @@ register_t get_default_hcr_flags(void); */ #define SYNCHRONIZE_SERROR(feat) \ do { \ - ASSERT(!cpus_have_cap(feat) || local_abort_is_enabled()); \ + ASSERT(local_abort_is_enabled()); \ asm volatile(ALTERNATIVE("dsb sy; isb", \ "nop; nop", feat) \ : : : "memory"); \ From patchwork Thu Oct 31 15:09:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 178204 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2980656ill; Thu, 31 Oct 2019 08:11:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaB2oabx9DvAI7zGs9eNC665K0G3rdJjoGgkH0WxDlzreU16v3QojVJZ7YBMqJBvRgg4uF X-Received: by 2002:a92:d38b:: with SMTP id o11mr6611598ilo.20.1572534698969; Thu, 31 Oct 2019 08:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572534698; cv=none; d=google.com; s=arc-20160816; b=cTKLJLOeAne/3Zscb12M9IJ5dYKvRXIc7L2SjBBbvZPIeNMv4V8HZ0pDugRFYa5QH9 usrHZ3Z2Uw+/9U9q1VNWTioYkkzn5pEI7GQZkv2H1a0R+jqs5jxpLLtiCsa+5oX0KQgL zzH9uyQp2mg5Yj8lRq/ZDpjk+klkFX68HDsrJz5QifusLqTaAps5XyLmRwWucM4L6FDy QRTFdblKWQVWHP9WC6s3+IXQusXCe0b1LnX5VEKl43hAJjie9Rfe40tnvqZJkEYoX7DB VdFLgJM+X6nmrrPTqq0iORCOufExGz5v76o4Oij887q8YxLH3kHsYqYUU0/GT1Jsjeav PWCg== 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=yYK7OKkW6arL8A9DYSLsohNIVLp9bBoUQ5CBKZUnGUc=; b=UTeKKATC07IYnSSfkRy34lXKvO6/hRj4FV6UFlZLCQYYuQiVXCs/6PuWR9ISfMOIIF 3e6V1AIxDeFNxInxA7WeWQmzZW7yHbPDSl1h99AlByG5KBiXEph14/IcuBRLfkG2IPn2 EZPF8CBPiJZz3kqhRIoGNpspRXRo243B7pP0ksd4jLElMVFBs4K91qtV5EzivyHbmnoy 11ohSeUYgRp+5Hk1lS0rBmrfufHkie1WPNkq26GaJzC6CnR8hMNQUBXc/e+J0HJKBQVi 8c6zGscf8VaW9IM9X+nb+8mepaH/hFeHsNzoKzvm8xK8BG1Qefu0GzhtoKTR2pU/QUHM n85w== 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 f6si7183043ilq.25.2019.10.31.08.11.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2019 08:11:38 -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 1iQC5x-0007wm-Nj; Thu, 31 Oct 2019 15:10:41 +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 1iQC5w-0007vT-Bl for xen-devel@lists.xenproject.org; Thu, 31 Oct 2019 15:10:40 +0000 X-Inumbo-ID: 7eeec6b6-fbf0-11e9-954c-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7eeec6b6-fbf0-11e9-954c-12813bfff9fa; Thu, 31 Oct 2019 15:09:56 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B34D895D; Thu, 31 Oct 2019 08:09:56 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (unknown [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B08BB3F71E; Thu, 31 Oct 2019 08:09:55 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 31 Oct 2019 15:09:22 +0000 Message-Id: <20191031150922.22938-20-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191031150922.22938-1-julien.grall@arm.com> References: <20191031150922.22938-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.13 v4 19/19] xen/arm: entry: Ensure the guest state is synced when receiving a vSError 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: jgross@suse.com, Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When a SError/Asynchronous Abort generated by the guest has been consumed, we will skip the handling of the initial exception. This includes the calls to enter_hypervisor_from_guest{, _noirq} that is used to synchronize part of the guest state with the internal representation and re-enable workarounds (e.g. SSBD). However, we still call leave_hypervisor_to_guest() which is used for preempting the guest and synchronizing back part of the guest state. enter_hypervisor_from_guest{, _noirq} works in pair with leave_hypervisor_to_guest(), so skipping the first two may result in a loss of some part of guest state. An example is the new vGIC which will save the state of the LRs on exit from the guest and rewrite all of them on entry to the guest. A more worrying example is SSBD workaround may not be re-enabled. If leave_hypervisor_to_guest() is rescheduling the vCPU, then we may end to run a lot of code with SSBD workaroud disabled. For now, calling leave_hypervisor_to_guest() is not necessary when injecting a vSError to the guest. But it would still be good to give an opportunity to reschedule. So both enter_hypervisor_from_guest() and leave_hypervisor_to_guest() are called. Note that on arm64, the return value for check_pending_vserror is now stored in x19 instead of x0. This is because we want to keep the value across call to C-functions (x0, unlike x19, will not be saved by the callee). Take the opportunity to rename check_pending_vserror() to check_pending_guest_serror() as the function is dealing with host SError and *not* virtual SError. The documentation is also updated accross Arm32 and Arm64 to clarify how Xen is dealing with SError generated by the guest. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v4: - Rewording + typo Changes in v3: - Update comments in the code. - Update commit message - Add arm32 support There are two known issues without this patch applied: * The state of the vGIC when using the new version may be lost. * SSBD workaround may be kept disabled while rescheduling the guest. --- xen/arch/arm/arm32/entry.S | 57 ++++++++++++++++++++++++++++++++++++++-------- xen/arch/arm/arm64/entry.S | 54 ++++++++++++++++++++++++++++++++----------- 2 files changed, 88 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 34156c4404..b31056a616 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -27,6 +27,10 @@ /* * Actions that needs to be done after entering the hypervisor from the * guest and before the interrupts are unmasked. + * + * @return: + * r4: Set to a non-zero value if a pending Abort exception took place. + * Otherwise, it will be set to zero. */ arch_enter_hypervisor_from_guest_preirq: #ifdef CONFIG_ARM32_HARDEN_BRANCH_PREDICTOR @@ -56,18 +60,35 @@ arch_enter_hypervisor_from_guest_preirq: SAVE_ONE_BANKED(R11_fiq); SAVE_ONE_BANKED(R12_fiq); /* - * If the SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT has been set in the cpu - * feature, the checking of pending SErrors will be skipped. + * We may have entered the hypervisor with pending asynchronous Abort + * generated by the guest. If we need to categorize them, then + * we need to consume any outstanding asynchronous Abort. + * Otherwise, they can be consumed later on. */ alternative_if SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + mov r4, #0 /* r4 := No Abort was consumed */ b skip_check alternative_else_nop_endif /* - * Start to check pending virtual abort in the gap of Guest -> HYP - * world switch. + * Consume pending asynchronous Abort generated by the guest if any. + * + * The only way to consume an Abort interrupt is to unmask it. So + * Abort exception will be unmaked for a small window and then masked + * it again. + * + * It is fine to unmask asynchronous Abort exception as we fully + * control the state of the processor and only limited code will + * be executed if the exception returns (see do_trap_data_abort()). * - * Save ELR_hyp to check whether the pending virtual abort exception + * TODO: The asynchronous abort path should be reworked to + * inject the virtual asynchronous Abort in enter_hypervisor_* + * rather than do_trap_data_abort(). This should make easier to + * understand the path. + */ + + /* + * save elr_hyp to check whether the pending virtual abort exception * takes place while we are doing this trap exception. */ mrs r1, ELR_hyp @@ -112,11 +133,11 @@ abort_guest_exit_end: cmp r1, r2 /* - * Not equal, the pending virtual abort exception took place, the - * initial exception does not have any significance to be handled. - * Exit ASAP. + * Set r4 depending on whether an asynchronous abort were + * consumed. */ - bne return_from_trap + movne r4, #1 + moveq r4, #0 skip_check: b enter_hypervisor_from_guest_preirq @@ -179,12 +200,28 @@ ENDPROC(arch_enter_hypervisor_from_guest_preirq) 1: /* Trap from the guest */ + /* + * arch_enter_hypervisor_from_guest_preirq will return with r4 set to + * a non-zero value if an asynchronous Abort was consumed. + * + * When an asynchronous Abort has been consumed (r4 != 0), we may have + * injected a virtual asynchronous Abort to the guest. + * + * In this case, the initial exception will be discarded (PC has + * been adjusted by inject_vabt_exception()). However, we still + * want to give an opportunity to reschedule the vCPU. So we + * only want to skip the handling of the initial exception (i.e. + * do_trap_*()). + */ bl arch_enter_hypervisor_from_guest_preirq .if \guest_iflags != n cpsie \guest_iflags .endif - bl enter_hypervisor_from_guest + adr lr, 2f + cmp r4, #0 + adrne lr, return_from_trap + b enter_hypervisor_from_guest 2: /* We are ready to handle the trap, setup the registers and jump. */ diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index a8ba7ab961..d35855af96 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -184,18 +184,41 @@ .macro guest_vector compat, iflags, trap, save_x0_x1=1 entry hyp=0, compat=\compat, save_x0_x1=\save_x0_x1 /* - * The vSError will be checked while SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * is not set. If a vSError took place, the initial exception will be - * skipped. Exit ASAP + * We may have entered the hypervisor with pending SErrors + * generated by the guest. If we need to categorize them, then + * we need to check any outstanding SErrors will be consumed. + * + * The function check_pending_guest_serror() will unmask SError + * exception temporarily. This is fine to do before enter_* + * helpers are called because we fully control the state of the + * processor and only limited code willl be executed (see + * do_trap_hyp_serror()). + * + * When a SError has been consumed (x19 != 0), we may have injected a + * virtual SError to the guest. + * + * In this case, the initial exception will be discarded (PC has + * been adjusted by inject_vabt_exception()). However, we still + * want to give an opportunity to reschedule the vCPU. So we + * only want to skip the handling of the initial exception (i.e. + * do_trap_*()). + * + * TODO: The SErrors path should be reworked to inject the vSError in + * enter_hypervisor_* rather than do_trap_hyp_serror. This should make + * easier to understand the path. */ alternative_if_not SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - bl check_pending_vserror - cbnz x0, 1f + bl check_pending_guest_serror alternative_else_nop_endif bl enter_hypervisor_from_guest_preirq msr daifclr, \iflags bl enter_hypervisor_from_guest + + alternative_if SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + cbnz x19, 1f + alternative_else_nop_endif + mov x0, sp bl do_trap_\trap 1: @@ -436,13 +459,17 @@ return_from_trap: eret /* - * This function is used to check pending virtual SError in the gap of - * EL1 -> EL2 world switch. - * The x0 register will be used to indicate the results of detection. - * x0 -- Non-zero indicates a pending virtual SError took place. - * x0 -- Zero indicates no pending virtual SError took place. + * Consume pending SError generated by the guest if any. + * + * @return: + * x19: Set to a non-zero value if a pending Abort exception took place. + * Otherwise, it will be set to zero. + * + * Without RAS extension, the only way to consume a SError is to unmask + * it. So the function will unmask SError exception for a small window and + * then mask it again. */ -check_pending_vserror: +check_pending_guest_serror: /* * Save elr_el2 to check whether the pending SError exception takes * place while we are doing this sync exception. @@ -487,11 +514,12 @@ abort_guest_exit_end: /* * Not equal, the pending SError exception took place, set - * x0 to non-zero. + * x19 to non-zero. */ - cset x0, ne + cset x19, ne ret +ENDPROC(check_pending_guest_serror) /* * Exception vectors.