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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 9CE7AC43460 for ; Tue, 11 May 2021 08:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58811613CF for ; Tue, 11 May 2021 08:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbhEKIYV (ORCPT ); Tue, 11 May 2021 04:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbhEKIYU (ORCPT ); Tue, 11 May 2021 04:24:20 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B830AC06175F for ; Tue, 11 May 2021 01:23:14 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id x15so4560085oic.13 for ; Tue, 11 May 2021 01:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=usBH1qyQQe6ZPzFOrrb23X7llSmuVyi8/ugogrn0DiiqOcFmN5N23A+vwiQzhraS8I hDBFZmOD7bPeKqMqZo8QrZdYiEYJr1dbhBe6sko2QRH/zx40XZY3GPkkwPl9UxjZFfn4 0KdaSoHhakKATnZ5BycuKM7nP2yysbq/lXMJKS17VMx+LyOE4cGhILRdTMmMrIFtAVYt yLBpIZWcHgRzF08cwsvWrAiAKGtuftRwOnihWAWz5XF1DSmZR9uz8gd1yhW/ry9sz9L8 Fmf4BSKwOUGW2fBXegpREPe1+1QFb/nQomxM6kms+RmBvRLY5QXpBdgbdcBRgL89xVHx oBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=eLbSdPjpRIL7keDTCQQFtPyawdXGji4+NG7NjiQ+5bIy17jo9tnfhSpayF55TUyW6D aj8yaJfFNbaHSdeQEjzponPtfP6guDGZoM3k9OQvQjPNXp8HCckge9s8ct+iZ5AaWOdM 63JY62WZduDnjqLlBz6c0gYA1YXd1QUahqs6ECwsAUnNuuiiAwNL0GS0oSLQfMdMEHVv NWetvAux3+JTetxLJv+VI4SriA2nqL+323U1dTDS8hc9rMt3erKM2YT3cO4PpP/K0lVY cpHL0jgSR1Ga8r+GfOc8w32LA+AmX5KLgMoutAhZ1b68E+Ca9taQcxlzrCsMXHHXspXL /0zA== X-Gm-Message-State: AOAM533M46/Slg68dzOj1TbSyS925wEgvBLvvuhbcajL9kaHOTofmMI7 CL94eCSTlIrC0hLYymTrMYPwhkqqi5a7t1Bv4Tv3ew== X-Google-Smtp-Source: ABdhPJzIB4t03lWKbmxy3jCJsw9fAeIDQrCq1mc5kl0akqAeREBctE/IihK/+/BJ2lGPo6x8xW+oBaVTt8h+WzRQsHw= X-Received: by 2002:aca:f5c7:: with SMTP id t190mr2559324oih.67.1620721393989; Tue, 11 May 2021 01:23:13 -0700 (PDT) MIME-Version: 1.0 References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-3-maz@kernel.org> <871radvg9n.wl-maz@kernel.org> In-Reply-To: <871radvg9n.wl-maz@kernel.org> From: Fuad Tabba Date: Tue, 11 May 2021 09:22:37 +0100 Message-ID: Subject: Re: [PATCH 2/2] KVM: arm64: Commit pending PC adjustemnts before returning to userspace To: Marc Zyngier 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Hi Marc, On Tue, May 11, 2021 at 9:14 AM Marc Zyngier wrote: > > 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. Nothing that fails, just code that generates exceptions or emulates instructions at various points. That said, I think it should be straightforward to write a selftest for this. I'll give it a go. /fuad > 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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 17D4AC433B4 for ; Tue, 11 May 2021 08:35:01 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 5BAF461184 for ; Tue, 11 May 2021 08:35:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BAF461184 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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 90BCA4B495; Tue, 11 May 2021 04:23:18 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com 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 5ouo-0CyaCyE; Tue, 11 May 2021 04:23:17 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7D15F4B47C; Tue, 11 May 2021 04:23:17 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 05FFF4B3BC for ; Tue, 11 May 2021 04:23:16 -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 C+jRyL+om3s2 for ; Tue, 11 May 2021 04:23:14 -0400 (EDT) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id CFB6B4B396 for ; Tue, 11 May 2021 04:23:14 -0400 (EDT) Received: by mail-oi1-f180.google.com with SMTP id i81so18334719oif.6 for ; Tue, 11 May 2021 01:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=usBH1qyQQe6ZPzFOrrb23X7llSmuVyi8/ugogrn0DiiqOcFmN5N23A+vwiQzhraS8I hDBFZmOD7bPeKqMqZo8QrZdYiEYJr1dbhBe6sko2QRH/zx40XZY3GPkkwPl9UxjZFfn4 0KdaSoHhakKATnZ5BycuKM7nP2yysbq/lXMJKS17VMx+LyOE4cGhILRdTMmMrIFtAVYt yLBpIZWcHgRzF08cwsvWrAiAKGtuftRwOnihWAWz5XF1DSmZR9uz8gd1yhW/ry9sz9L8 Fmf4BSKwOUGW2fBXegpREPe1+1QFb/nQomxM6kms+RmBvRLY5QXpBdgbdcBRgL89xVHx oBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=Cz0hdx9SqsFGoitmZOuQcuTh7kRvR0XE1cSh2HlO7wAMuQcGL0N744GRKZFIYH6bHz J3nbsHGmfX1GXsFwfjqc5SOR+y/qNu+AzxMIzUqWH/YPTOB2cuKAV/qwZRCb0iPqAfpR lKbGCye9T0Ow96MlM0OMkfj3Dvy91KQJnCT184AM1NtrkSRbNDCN14ItlMKRHcH96Y3a a68HNgszKsd7lgJB1kOBakWW/hKMlCDYAfX53brikYoChZdAAqSZmU1Xy/MUe4RC51nU Jc8fdvSbJ+K173wSepYdVa6KG16viPWJnsyq5XBEZxWjqyQmiQM9X9r0Rr4gVG3zaQO1 JGMA== X-Gm-Message-State: AOAM531joj3R+8/NYF3i0T7OMzTFDFGn8Q8DVCJlpYOJIqHW7jWAKIEf 46jL9WQNUj9jnwTlA/atuO6r6R4RFjq0dq3MIbEtNw== X-Google-Smtp-Source: ABdhPJzIB4t03lWKbmxy3jCJsw9fAeIDQrCq1mc5kl0akqAeREBctE/IihK/+/BJ2lGPo6x8xW+oBaVTt8h+WzRQsHw= X-Received: by 2002:aca:f5c7:: with SMTP id t190mr2559324oih.67.1620721393989; Tue, 11 May 2021 01:23:13 -0700 (PDT) MIME-Version: 1.0 References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-3-maz@kernel.org> <871radvg9n.wl-maz@kernel.org> In-Reply-To: <871radvg9n.wl-maz@kernel.org> From: Fuad Tabba Date: Tue, 11 May 2021 09:22:37 +0100 Message-ID: Subject: Re: [PATCH 2/2] KVM: arm64: Commit pending PC adjustemnts before returning to userspace To: Marc Zyngier 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 Marc, On Tue, May 11, 2021 at 9:14 AM Marc Zyngier wrote: > > 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. Nothing that fails, just code that generates exceptions or emulates instructions at various points. That said, I think it should be straightforward to write a selftest for this. I'll give it a go. /fuad > 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.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 E4EA6C433B4 for ; Tue, 11 May 2021 12:13:39 +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 357D46187E for ; Tue, 11 May 2021 12:13:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 357D46187E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QSxhKT7l0FYRvG41aLjlxdRAPpvAtt2G/aS79/Tn/x0=; b=W9wTseGXUZqU2vr4KUdp9nLar 4H6jBMM3hsF98a1VAcd/Ia9edgqHZ818KaGZVdaOswpw99GyVYgYqPDdlHFJojB9+9RtuyJ8WAB/b G6wCQVmEF9j/mR+4H5IfXzARsQQgpgzmcDoz3UaXGGc70jND9+AqiwY1cECIO49mCV7qsZNPXEfLR LJ7kFEe631SvRc66wyrnpZngbfSzRr4UUvm49epC+wf4RQV5CbV8KkqUt6pjANDcocdu96vefOBzL G1qob0LHWak+x+Ko0OsYAur+kEGaDYe7xjI3Q92Vu86oOQGeeejPMpFmBf5D6RDwPNVIFuyoA/Mbc E8nrNoGkA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgRFN-00HJSz-0q; Tue, 11 May 2021 12:12:21 +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 1lgNfi-00GaoY-Lo for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 08:23:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=pXHGFC0jn6y9fuSg8IJHQwA682 qBhl8CRmbVw7AFzOo/+HZpKH3HIF1ZA2P8XQ/qnPMnjrFVq/cN+tOF493utgpgmUejlxh8gBRDgSW Cf5mbyxNCHVN5tF3n/wKEYY8M5KNHhbBEHQ/4FUnNRws+GO0HL3OFNsxpRbe9mmCXpGitkEvKL5RN YZROEdZ7e61ULKz5jPoDe9c6Cm2LIYaqaSceE+jheFBoS/sYh78ctZBBUGvog3tfhWNYkzc08oOlK k6I9lOGnM2QwmspJxTSnTSwElZGGoae+QHflor/hnjCnNfQqg9K7T/oLoji0pf6tN7AZyl8xX0k2B jbA2/uyw==; Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgNff-009OM2-Lo for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 08:23:17 +0000 Received: by mail-oi1-x230.google.com with SMTP id u16so18327626oiu.7 for ; Tue, 11 May 2021 01:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=usBH1qyQQe6ZPzFOrrb23X7llSmuVyi8/ugogrn0DiiqOcFmN5N23A+vwiQzhraS8I hDBFZmOD7bPeKqMqZo8QrZdYiEYJr1dbhBe6sko2QRH/zx40XZY3GPkkwPl9UxjZFfn4 0KdaSoHhakKATnZ5BycuKM7nP2yysbq/lXMJKS17VMx+LyOE4cGhILRdTMmMrIFtAVYt yLBpIZWcHgRzF08cwsvWrAiAKGtuftRwOnihWAWz5XF1DSmZR9uz8gd1yhW/ry9sz9L8 Fmf4BSKwOUGW2fBXegpREPe1+1QFb/nQomxM6kms+RmBvRLY5QXpBdgbdcBRgL89xVHx oBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=045C15kVflz7mRdOnafmMq48e1iREZTBgktY8+UlBLQ=; b=WS6RCePxwmihC5UlNTQ1loaMmLiUISVVtoqiZzqXae0zsHCrwv0qklYzaev3ThFLPw IWGozic4SoY/6LPb+3gfW37NDTadpEvNBOS0gfYpBBRlIUCLsLafAHbo+UX1Jo9dE09z BARfgu+C9RtHSCI8U69IDNtI3hzCYC/v8HsXODaFYv8S96zR9bgUAAPhtlFoP0WtB1Ks e7JGIPI7CwuccH/rPzpXA9Qvl1p8fVyW7eoNqUM2hviS5vNcRdj83TLidT1M5uJZTu37 pjMk8jwognLJdEu3UVhgj5atSgKUBppBpk6lT2BoftZB68ri2JPWcuPcb1uccBUxtDln pHoQ== X-Gm-Message-State: AOAM530lgdOuVBe4Hbu9+7ucYx7jJSM/NMT+/P2S45sr1vLV8XPKHBvP 0Ydnr8eunOAgV0CXgfHVrafBcEsL7K6vkT+yj9kpBA== X-Google-Smtp-Source: ABdhPJzIB4t03lWKbmxy3jCJsw9fAeIDQrCq1mc5kl0akqAeREBctE/IihK/+/BJ2lGPo6x8xW+oBaVTt8h+WzRQsHw= X-Received: by 2002:aca:f5c7:: with SMTP id t190mr2559324oih.67.1620721393989; Tue, 11 May 2021 01:23:13 -0700 (PDT) MIME-Version: 1.0 References: <20210510094915.1909484-1-maz@kernel.org> <20210510094915.1909484-3-maz@kernel.org> <871radvg9n.wl-maz@kernel.org> In-Reply-To: <871radvg9n.wl-maz@kernel.org> From: Fuad Tabba Date: Tue, 11 May 2021 09:22:37 +0100 Message-ID: Subject: Re: [PATCH 2/2] KVM: arm64: Commit pending PC adjustemnts before returning to userspace To: Marc Zyngier 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_012315_757281_056B8F73 X-CRM114-Status: GOOD ( 24.84 ) /bin/ln: failed to access 'reaver_cache/texts/20210511_012315_757281_056B8F73': No such file or directory X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_012315_757281_056B8F73 X-CRM114-Status: GOOD ( 21.39 ) 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 Marc, On Tue, May 11, 2021 at 9:14 AM Marc Zyngier wrote: > > 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. Nothing that fails, just code that generates exceptions or emulates instructions at various points. That said, I think it should be straightforward to write a selftest for this. I'll give it a go. /fuad > 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