From patchwork Tue Dec 4 20:26:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 152858 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8503520ljp; Tue, 4 Dec 2018 12:29:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wh8IypFonyBx2lgLBMv9G1eq9nijAl6z+kfKDRU/FgWBpHyG5NliMzDkBJARty+g4YQpLt X-Received: by 2002:a81:ad60:: with SMTP id l32mr21112532ywk.64.1543955375144; Tue, 04 Dec 2018 12:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955375; cv=none; d=google.com; s=arc-20160816; b=jDHn6fgZ2J7B0OCb6mE+k4LlRHaR0ubqG/lT2kXhREiyn2YWk3CpsheaAKF323kBQV hsaAo3QqhuibHMkLIQz5PuhNVuCrYCEszDJ+JBf5qR4i7SW5o8UI4NaV0WQlJluVn2CH KpOICAywjcODJZtWZ0vDGQNKswvjEOM20tZ4WkbfdfzmJ0FERBd4MOjdAJr7lYSpGA34 n/NiKCjdNUpaZAE1dd87ZtVsWT7K76Ou5Y+Y45ohoaTWU1P6f/MEHxCvTSjSjMcUXyps W9zJbarrSgZCuNIj9GZGz4BPLxuaEFf9cYATsgSNcdGSHwSD2fAYHn0CeJZwm/WsYxdp E9WA== 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=b2mpAIk3tIeqSrVOLQhPz0VkkZ4vRcmNgGsp40wXIeY=; b=WJphCB65oQNOYgulzpwsgMIjLSKpYzRB864A5SdRTrevjmuGvwKlbZeEZgXjgcuv43 I2d+powvoIaWq/FLAKDbseI2Hw/3y3h2yPlNg8CRrZkYfFDNg+SZOSsOSsRdMiid1rKw 3XhH1vgN+K/1t13dLz7vCRvyooVRDPEzEEzBdT6IpoJuuYj4v/d34X/HC2/tzrCStRTM xAhO7W+EX5/ZeJVpYa+0rAX3yoMaE0jevhk8hcr0qU9wWTlSfIL3VrYU+5XurjiyfSny 4F/OAyGhAJ1fvo3wnVVNvhTkYiLwTE49Z5hptg/5YMYzi6Xj6GPnUtfg0bJnNLqXDkOW q2Iw== 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 s206si6135759ybc.235.2018.12.04.12.29.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 12:29:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gUHI5-0008DZ-WE; Tue, 04 Dec 2018 20:27:33 +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 1gUHI4-00089v-24 for xen-devel@lists.xenproject.org; Tue, 04 Dec 2018 20:27:32 +0000 X-Inumbo-ID: 06120688-f803-11e8-8189-6bdc23c5bb6b Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 06120688-f803-11e8-8189-6bdc23c5bb6b; Tue, 04 Dec 2018 20:27:30 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60A7F165C; Tue, 4 Dec 2018 12:27:30 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 984AF3F614; Tue, 4 Dec 2018 12:27:29 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Dec 2018 20:26:46 +0000 Message-Id: <20181204202651.8836-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181204202651.8836-1-julien.grall@arm.com> References: <20181204202651.8836-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 12/17] xen/arm: traps: Rework leave_hypervisor_tail X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function leave_hypervisor_tail is called before each return to the guest vCPU. It has two main purposes: 1) Process physical CPU work (e.g rescheduling) if required 2) Prepare the physical CPU to run the guest vCPU 2) will always be done once we finished to process physical CPU work. At the moment, it is done part of the last iterations of 1) making adding some extra indentation in the code. This could be streamlined by moving out 2) of the loop. At the same time, 1) is moved in a separate function making more obvious All those changes will help a follow-up patch where we would want to introduce some vCPU work before returning to the guest vCPU. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/traps.c | 61 ++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index b00d0b8e1e..02665cc7b4 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2241,36 +2241,12 @@ void do_trap_fiq(struct cpu_user_regs *regs) gic_interrupt(regs, 1); } -void leave_hypervisor_tail(void) +static void check_for_pcpu_work(void) { - while (1) - { - local_irq_disable(); - if ( !softirq_pending(smp_processor_id()) ) - { - vgic_sync_to_lrs(); - - /* - * If the SErrors handle option is "DIVERSE", we have to prevent - * slipping the hypervisor SError to guest. In this option, before - * returning from trap, we have to synchronize SErrors to guarantee - * that the pending SError would be caught in hypervisor. - * - * If option is NOT "DIVERSE", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT - * will be set to cpu_hwcaps. This means we can use the alternative - * to skip synchronizing SErrors for other SErrors handle options. - */ - SYNCHRONIZE_SERROR(SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT); - - /* - * The hypervisor runs with the workaround always present. - * If the guest wants it disabled, so be it... - */ - if ( needs_ssbd_flip(current) ) - arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL); + ASSERT(!local_irq_is_enabled()); - return; - } + while ( softirq_pending(smp_processor_id()) ) + { local_irq_enable(); do_softirq(); /* @@ -2278,9 +2254,38 @@ void leave_hypervisor_tail(void) * and we want to patch the hypervisor with almost no stack. */ check_for_livepatch_work(); + local_irq_disable(); } } +void leave_hypervisor_tail(void) +{ + local_irq_disable(); + + check_for_pcpu_work(); + + vgic_sync_to_lrs(); + + /* + * If the SErrors handle option is "DIVERSE", we have to prevent + * slipping the hypervisor SError to guest. In this option, before + * returning from trap, we have to synchronize SErrors to guarantee + * that the pending SError would be caught in hypervisor. + * + * If option is NOT "DIVERSE", SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT + * will be set to cpu_hwcaps. This means we can use the alternative + * to skip synchronizing SErrors for other SErrors handle options. + */ + SYNCHRONIZE_SERROR(SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT); + + /* + * The hypervisor runs with the workaround always present. + * If the guest wants it disabled, so be it... + */ + if ( needs_ssbd_flip(current) ) + arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL); +} + /* * Local variables: * mode: C