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 AEF46C433B4 for ; Tue, 11 May 2021 08:14:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7009C61928 for ; Tue, 11 May 2021 08:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbhEKIPh (ORCPT ); Tue, 11 May 2021 04:15:37 -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: stable@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. 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,URIBL_BLOCKED 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 22C4BC43461 for ; Tue, 11 May 2021 08:14:36 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 57E1F61494 for ; Tue, 11 May 2021 08:14:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57E1F61494 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BB28C4B4AB; Tue, 11 May 2021 04:14:34 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WeCy5Yu+vHoM; Tue, 11 May 2021 04:14:33 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 75C7D4B47C; Tue, 11 May 2021 04:14:33 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2C8044B466 for ; Tue, 11 May 2021 04:14:32 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 122-7IeWplEl for ; Tue, 11 May 2021 04:14:31 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 13D8A4B41D for ; Tue, 11 May 2021 04:14:31 -0400 (EDT) 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 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") 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 Cc: kvm@vger.kernel.org, kernel-team@android.com, stable@vger.kernel.org, "open list:KERNEL VIRTUAL MACHINE FOR ARM64 \(KVM/arm64\)" , "moderated list:ARM64 PORT \(AARCH64 ARCHITECTURE\)" X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 98C3EC433ED for ; Tue, 11 May 2021 12:09:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F03966187E for ; Tue, 11 May 2021 12:09:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F03966187E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Subject:Cc:To: From:Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ez/n6EsftX03hgN4FaIb3JLKP1rTBo83r2THn+Ymo3g=; b=Hai9r5/lxRfCAnaaYkEarJ8pt fCKenPG/VWwOpJJ62rwv6Zzepkvq4/cX/sfxLNlj/gUfHuWA1rmGIbRMVSq98zzUw7qRtpqTUD/jE ziTEUcbB3MenBytaMrSeAt09mPdFgNlYmt9GoJ5+NmQvDhfnhwa/cI/bB+kURrZORA02mS8vtDMHp ZHDznJDRP918HPcad86oH/28TAV6C0xfxzSMaZS49SMG7hF+D+84tv7PGcXpJ8jOhE+jMgO2WE0B/ QT281v3qyJfX/OFfi3zzpXuCT/q+Wvbn6emIqv4L57mudWm8jC6+mbZyE34cGfoecitxPRT++QLnx mi4OLoagA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgRB5-00HIM2-4c; Tue, 11 May 2021 12:07:56 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgNXJ-00GZk2-B9 for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 08:14:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OaYuIUQYQecUEz5ajWyWHs1jNPdbHw4e0Ak+7qi/rZ8=; b=kWdWwcSrlzxpCPWsdhqvGu9Tz5 Gssxs0Qd+JOm66XRJ6HM/GG//lLsrEawsmXv95cUNnJG/LxWGiRlZa/AVxgoZ47yfX+iCxmkMBzDc eUdX+WRgfY5t6EIMwmp9Dpu+U47IwJ8A1AO6mohvvb5CwkRJt9qSHWpa893IEbZbGIcdxmiYLY+Di hXBKVWxF+dS2Dtb6EtJ7XVFzYfZivRGeWM5yLaO/73/p/AfuEV0eL/bCQ0sxSYKc9BFg8d4MBy+aB du3OmumY4Kg3ue729HXUPQW5ZW13KxhsKig5tqO01SB7e6s+JT2i0SGix0ZTDN1I4k3IoFCAwS84v 6MUIrWXA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgNXF-009O7C-IF for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 08:14:34 +0000 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_011433_665504_94128485 X-CRM114-Status: GOOD ( 24.48 ) /bin/ln: failed to access 'reaver_cache/texts/20210511_011433_665504_94128485': No such file or directory X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_011433_665504_94128485 X-CRM114-Status: GOOD ( 20.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel