From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4788DC43460 for ; Tue, 11 May 2021 08:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D77161928 for ; Tue, 11 May 2021 08:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbhEKIPi (ORCPT ); Tue, 11 May 2021 04:15:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:51742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbhEKIPg (ORCPT ); Tue, 11 May 2021 04:15:36 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB0A4613C0; Tue, 11 May 2021 08:14:29 +0000 (UTC) Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lgNX9-000ctp-Qk; Tue, 11 May 2021 09:14:27 +0100 Date: Tue, 11 May 2021 09:14:28 +0100 Message-ID: <871radvg9n.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvm@vger.kernel.org, "open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , Zenghui Yu , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: arm64: Commit pending PC adjustemnts before returning to userspace In-Reply-To: References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-3-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: tabba@google.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, kernel-team@android.com, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Fuad, On Tue, 11 May 2021 09:03:40 +0100, Fuad Tabba wrote: > > Hi Marc, > > > KVM: arm64: Commit pending PC adjustemnts before returning to userspace > > s/adjustments/adjustments Looks like Gmail refuses to let you mimic my spelling mistakes! :D > > On Mon, May 10, 2021 at 10:49 AM Marc Zyngier wrote: > > > > KVM currently updates PC (and the corresponding exception state) > > using a two phase approach: first by setting a set of flags, > > then by converting these flags into a state update when the vcpu > > is about to enter the guest. > > > > However, this creates a disconnect with userspace if the vcpu thread > > returns there with any exception/PC flag set. In this case, the exposed > > context is wrong, as userpsace doesn't have access to these flags > > (they aren't architectural). It also means that these flags are > > preserved across a reset, which isn't expected. > > > > To solve this problem, force an explicit synchronisation of the > > exception state on vcpu exit to userspace. As an optimisation > > for nVHE systems, only perform this when there is something pending. > > I've tested this with a few nvhe and vhe tests that exercise both > __kvm_adjust_pc call paths (__kvm_vcpu_run and > kvm_arch_vcpu_ioctl_run), and the tests ran as expected. I'll do the > same for v2 when you send it out. Ah, that's interesting. Do you have tests that actually fail when hitting this bug? Given that this is pretty subtle, it'd be good to have a way to make sure it doesn't crop up again. Thanks, M. -- Without deviation from the norm, progress is not possible.