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); }