From patchwork Thu Jan 26 23:54:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 48977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553070wrn; Thu, 26 Jan 2023 16:01:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXslm3ek7//DCK3t0y8tiDRth1cftuQ3tbpN1Iq886nfhcLIP8vMjqY0EPTdHTmgtkDZjklR X-Received: by 2002:a17:906:60d2:b0:872:6bd0:d2b with SMTP id f18-20020a17090660d200b008726bd00d2bmr35582131ejk.45.1674777674183; Thu, 26 Jan 2023 16:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674777674; cv=none; d=google.com; s=arc-20160816; b=So7bm+LRF6hp0ouKmhQW4Clc0iXmhy2mgJVzi3bUa/S8WiRfTyank62c4dYJR4rsPh NvCu4iDJj2umfqTu7ULl5s2uPQVT0+I1fY8GM4T2IRXDYgaN5hmDxXnzQR+ywoEVkyOd RENUVvR8pIfHtXBO75GLhyCQgoDPf3aFrUxzdiwUmKVrHc48+9EbCW4EL517Vf8SOI69 MFUflCNHZRwqI64pKrUzDLqz/fVeuMzPa02nD8Lsos4vI6AF6HhjMuF2oWS++0YzIqs+ OsdTfUG+r8ttNe2buooX+3c+wpVl+GSjdRI4KymHlrB7qt1c6psKSkCTtKhc27JBmli9 p4ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kli5sE9lIHwCvZbbt0ccDIlIdit3t3RFH2I2s6WRBok=; b=KwQ9Bds6mqG/g6/dngJwOEtK9XF9SobZnim66H2kcit/MIX6HPc5ZsNnAs8TNsn1Fg YJJDXF9ibLr9G228ur7Q3LAg3WtQjhcNdLDdM087ki0cEnvQ0q6RPxqD4gQhE22If8nv qyCb2+I8XENqGQoYIhYsgah0gWeDZQRsQGUtzWP8lChbKLCRGY4irUqKhFz2c4LUJcK2 j9lR++IcEUxMs25o0Igp/5wwoeYCpmIFojY/QnEB2VhoXmthG4BdO6p4RDgmGK/SB7cY fuihZV2C9IbwpY389s78+UpZcDekGyUoyTwQtwfLf3iUs/HT8v/OZy6LbKVhd2FQbCEe 6hKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Glm22DMf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a50cc8c000000b004a091925e42si3220088edi.116.2023.01.26.16.00.49; Thu, 26 Jan 2023 16:01:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Glm22DMf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjAZX4N (ORCPT + 99 others); Thu, 26 Jan 2023 18:56:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233589AbjAZX4J (ORCPT ); Thu, 26 Jan 2023 18:56:09 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1611F458A1 for ; Thu, 26 Jan 2023 15:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674777317; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kli5sE9lIHwCvZbbt0ccDIlIdit3t3RFH2I2s6WRBok=; b=Glm22DMfY3P2GvGbED4dOp+Y4x4yC/90aQI7m8BigwEE65biwrfoyHspa4S36bmsAuZLVX LwSCIw4JF8kT1kKOlOrDDvV2zr+O0t3jhAWFzFXtRS4RZzNxd/hLL2iroYWf2VdiMTXt6J cixnfxI0HAf1vr3nlqvHfYk6AEJMJlA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-RgZNoq5vNEqcDzBpmEVZzw-1; Thu, 26 Jan 2023 18:55:13 -0500 X-MC-Unique: RgZNoq5vNEqcDzBpmEVZzw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF22B1C05AAA; Thu, 26 Jan 2023 23:55:12 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-98.bne.redhat.com [10.64.54.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 647E92166B29; Thu, 26 Jan 2023 23:55:04 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.linux.dev Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yuzhe@nfschina.com, isaku.yamahata@intel.com, seanjc@google.com, ricarkol@google.com, eric.auger@redhat.com, renzhengeek@gmail.com, reijiw@google.com, shan.gavin@gmail.com Subject: [PATCH v3 1/4] KVM: arm64: Include kvm_mmu.h from vgic.h Date: Fri, 27 Jan 2023 07:54:48 +0800 Message-Id: <20230126235451.469087-2-gshan@redhat.com> In-Reply-To: <20230126235451.469087-1-gshan@redhat.com> References: <20230126235451.469087-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756131674115600848?= X-GMAIL-MSGID: =?utf-8?q?1756131674115600848?= We need a unified helper in 'kvm/vgic/vgic.h' to write guest memory. In the helper, the check of no-running-vcpu context for dirty ring will be applied. kvm_write_guest_lock(), defined in 'include/asm/kvm_mmu.h', is going to be dereferenced by the unified helper. Include 'include/asm/kvm_mmu.h' to 'kvm/vgic/vgic.h' to avoid including the former header file when the later one is needed. With the change, the duplicate inclusions of 'include/asm/kvm_mmu.h' are removed. No functional change intended. Suggested-by: Oliver Upton Signed-off-by: Gavin Shan --- arch/arm64/kvm/vgic/vgic-debug.c | 1 - arch/arm64/kvm/vgic/vgic-init.c | 1 - arch/arm64/kvm/vgic/vgic-its.c | 1 - arch/arm64/kvm/vgic/vgic-kvm-device.c | 1 - arch/arm64/kvm/vgic/vgic-mmio-v3.c | 1 - arch/arm64/kvm/vgic/vgic-v2.c | 1 - arch/arm64/kvm/vgic/vgic-v3.c | 1 - arch/arm64/kvm/vgic/vgic.h | 1 + 8 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c index 78cde687383c..69201c2dfc6c 100644 --- a/arch/arm64/kvm/vgic/vgic-debug.c +++ b/arch/arm64/kvm/vgic/vgic-debug.c @@ -10,7 +10,6 @@ #include #include #include -#include #include "vgic.h" /* diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index f6d4f4052555..de389a5bec45 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "vgic.h" /* diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 94a666dd1443..ad4bb69ab83e 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -18,7 +18,6 @@ #include #include -#include #include "vgic.h" #include "vgic-mmio.h" diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c index edeac2380591..552668a91bd9 100644 --- a/arch/arm64/kvm/vgic/vgic-kvm-device.c +++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include "vgic.h" diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 91201f743033..8ba04f4fa63d 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -13,7 +13,6 @@ #include #include -#include #include "vgic.h" #include "vgic-mmio.h" diff --git a/arch/arm64/kvm/vgic/vgic-v2.c b/arch/arm64/kvm/vgic/vgic-v2.c index 645648349c99..d8604fdfdfcd 100644 --- a/arch/arm64/kvm/vgic/vgic-v2.c +++ b/arch/arm64/kvm/vgic/vgic-v2.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "vgic.h" diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 2074521d4a8c..5dfbd03e5e1a 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "vgic.h" diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index 0c8da72953f0..056425e3a490 100644 --- a/arch/arm64/kvm/vgic/vgic.h +++ b/arch/arm64/kvm/vgic/vgic.h @@ -6,6 +6,7 @@ #define __KVM_ARM_VGIC_NEW_H__ #include +#include #define PRODUCT_ID_KVM 0x4b /* ASCII code K */ #define IMPLEMENTER_ARM 0x43b From patchwork Thu Jan 26 23:54:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 48976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp552690wrn; Thu, 26 Jan 2023 16:00:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMp9f/2fQmSj8XS9MP/pSN1A69e+nhiJpTEDzxxEhpB858R8K3RHeaP82QgywO9sR2myAu X-Received: by 2002:a05:6402:1cb9:b0:49e:ef1f:712e with SMTP id cz25-20020a0564021cb900b0049eef1f712emr25295145edb.18.1674777631477; Thu, 26 Jan 2023 16:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674777631; cv=none; d=google.com; s=arc-20160816; b=TYXqDTMb8YHJ3GHxY1qpS7gn6ysVyt7OEqNOqQv5r9oHQahdUEj++gfMHVSG/UScEi 4EEi7SsV9amrObpwJJz15EF4R9pldxgzSL2Mhrs39n3y2kyeTa+FRCkEcjG6wX6Tufw+ 9Rypi3xkLg9Z6tywLRD4lFr+hzGTCobemt+qikJMMdo5rk0CuzV8fzJ0G/5hJ5rroSOr FjvrIx3Nlsvu+iPxyYDJbGiMTteds7KOO5OpIScPRDriVhhSUH9iBlfmCE4urEu+w4DZ zG4/BuQ6PFc+JFZPKkH+C49RBtCESpJiTZQw21xBPKCEwKzz/8SFRrwgG7hMhW7+N9ee SdmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x/0EMt1THyulqv9ZI+2w89IGqHaZMQ5iccsFYm5z1og=; b=gljMOCd+bhcXyfFWC9glFKgny3g1mqb0uIT7MKmU0xy4qgc9PtJ4r5qP3K7LgcsWs9 emzWLCydJ+0Ash1ZGl+QcYZLjVEULHcHBK7VSwJ7uJGFrxsLcCQxLC3aXI2gvweC7qJK hVtX6ugIhL5/WXyOKD8dUuAZ+yXCmfdhdMp/YGn8JVHBevDnCHoxskPih24HzVvV8E3w XpF71qWBVm5u0g1mx0vDugtZxUuf2HPao7UrAmR5OaGC6bYHNOi9uzY1ihhMTcdAkThU 16Hl+E0uFCtfnKeAsxUztTT91Kb5YdRS0mQKwR29DYFGKN7jXDrSvCR/tSoodeBX90sc VbxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Amrl1YKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a509b0a000000b004a0b150f031si3210185edi.73.2023.01.26.16.00.07; Thu, 26 Jan 2023 16:00:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Amrl1YKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbjAZX4W (ORCPT + 99 others); Thu, 26 Jan 2023 18:56:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbjAZX4R (ORCPT ); Thu, 26 Jan 2023 18:56:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D04A0457FF for ; Thu, 26 Jan 2023 15:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674777326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x/0EMt1THyulqv9ZI+2w89IGqHaZMQ5iccsFYm5z1og=; b=Amrl1YKKm5SbyDDaIuyQYRN81Q9d0SUYwd3gqPEJFo88/C5BiS32tszEgST1+CwpAjaEbC KmBGNVMwaw1ey9R20pGdKt7xiOSqZr8jS/ugLcMim7qeL+vfSBPAtA6eXnXBotLKrBZ5wb tqSPCDdqYPTpwHl1sN0AhuGD7fLbfpQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-c6_-ctMeOP2_gwuiYcznTg-1; Thu, 26 Jan 2023 18:55:22 -0500 X-MC-Unique: c6_-ctMeOP2_gwuiYcznTg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47C0A38012C9; Thu, 26 Jan 2023 23:55:21 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-98.bne.redhat.com [10.64.54.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90C162166B26; Thu, 26 Jan 2023 23:55:13 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.linux.dev Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yuzhe@nfschina.com, isaku.yamahata@intel.com, seanjc@google.com, ricarkol@google.com, eric.auger@redhat.com, renzhengeek@gmail.com, reijiw@google.com, shan.gavin@gmail.com Subject: [PATCH v3 2/4] KVM: arm64: Add helper vgic_write_guest_lock() Date: Fri, 27 Jan 2023 07:54:49 +0800 Message-Id: <20230126235451.469087-3-gshan@redhat.com> In-Reply-To: <20230126235451.469087-1-gshan@redhat.com> References: <20230126235451.469087-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756131629816437607?= X-GMAIL-MSGID: =?utf-8?q?1756131629816437607?= Currently, the unknown no-running-vcpu sites are reported when a dirty page is tracked by mark_page_dirty_in_slot(). Until now, the only known no-running-vcpu site is saving vgic/its tables through KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} command on KVM device "kvm-arm-vgic-its". Unfortunately, there are more unknown sites to be handled and no-running-vcpu context will be allowed in these sites: (1) KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} command on KVM device "kvm-arm-vgic-its" to restore vgic/its tables. The vgic3 LPI pending status could be restored. (2) Save vgic3 pending table through KVM_DEV_ARM_{VGIC_GRP_CTRL, VGIC_SAVE_PENDING_TABLES} command on KVM device "kvm-arm-vgic-v3". In order to handle those unknown cases, we need a unified helper vgic_write_guest_lock(). struct vgic_dist::save_its_tables_in_progress is also renamed to struct vgic_dist::save_tables_in_progress. No functional change intended. Suggested-by: Oliver Upton Signed-off-by: Gavin Shan Reviewed-by: Oliver Upton --- arch/arm64/kvm/vgic/vgic-its.c | 13 +++++-------- arch/arm64/kvm/vgic/vgic.h | 13 +++++++++++++ include/kvm/arm_vgic.h | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index ad4bb69ab83e..887dfa6cc79d 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -2186,7 +2186,7 @@ static int vgic_its_save_ite(struct vgic_its *its, struct its_device *dev, ((u64)ite->irq->intid << KVM_ITS_ITE_PINTID_SHIFT) | ite->collection->collection_id; val = cpu_to_le64(val); - return kvm_write_guest_lock(kvm, gpa, &val, ite_esz); + return vgic_write_guest_lock(kvm, gpa, &val, ite_esz); } /** @@ -2338,7 +2338,7 @@ static int vgic_its_save_dte(struct vgic_its *its, struct its_device *dev, (itt_addr_field << KVM_ITS_DTE_ITTADDR_SHIFT) | (dev->num_eventid_bits - 1)); val = cpu_to_le64(val); - return kvm_write_guest_lock(kvm, ptr, &val, dte_esz); + return vgic_write_guest_lock(kvm, ptr, &val, dte_esz); } /** @@ -2525,7 +2525,7 @@ static int vgic_its_save_cte(struct vgic_its *its, ((u64)collection->target_addr << KVM_ITS_CTE_RDBASE_SHIFT) | collection->collection_id); val = cpu_to_le64(val); - return kvm_write_guest_lock(its->dev->kvm, gpa, &val, esz); + return vgic_write_guest_lock(its->dev->kvm, gpa, &val, esz); } /* @@ -2606,7 +2606,7 @@ static int vgic_its_save_collection_table(struct vgic_its *its) */ val = 0; BUG_ON(cte_esz > sizeof(val)); - ret = kvm_write_guest_lock(its->dev->kvm, gpa, &val, cte_esz); + ret = vgic_write_guest_lock(its->dev->kvm, gpa, &val, cte_esz); return ret; } @@ -2742,7 +2742,6 @@ static int vgic_its_has_attr(struct kvm_device *dev, static int vgic_its_ctrl(struct kvm *kvm, struct vgic_its *its, u64 attr) { const struct vgic_its_abi *abi = vgic_its_get_abi(its); - struct vgic_dist *dist = &kvm->arch.vgic; int ret = 0; if (attr == KVM_DEV_ARM_VGIC_CTRL_INIT) /* Nothing to do */ @@ -2762,9 +2761,7 @@ static int vgic_its_ctrl(struct kvm *kvm, struct vgic_its *its, u64 attr) vgic_its_reset(kvm, its); break; case KVM_DEV_ARM_ITS_SAVE_TABLES: - dist->save_its_tables_in_progress = true; ret = abi->save_tables(its); - dist->save_its_tables_in_progress = false; break; case KVM_DEV_ARM_ITS_RESTORE_TABLES: ret = abi->restore_tables(its); @@ -2791,7 +2788,7 @@ bool kvm_arch_allow_write_without_running_vcpu(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; - return dist->save_its_tables_in_progress; + return dist->save_tables_in_progress; } static int vgic_its_set_attr(struct kvm_device *dev, diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index 056425e3a490..3804b3e946fd 100644 --- a/arch/arm64/kvm/vgic/vgic.h +++ b/arch/arm64/kvm/vgic/vgic.h @@ -132,6 +132,19 @@ static inline bool vgic_irq_is_multi_sgi(struct vgic_irq *irq) return vgic_irq_get_lr_count(irq) > 1; } +static inline int vgic_write_guest_lock(struct kvm *kvm, gpa_t gpa, + const void *data, unsigned long len) +{ + struct vgic_dist *dist = &kvm->arch.vgic; + int ret; + + dist->save_tables_in_progress = true; + ret = kvm_write_guest_lock(kvm, gpa, data, len); + dist->save_tables_in_progress = false; + + return ret; +} + /* * This struct provides an intermediate representation of the fields contained * in the GICH_VMCR and ICH_VMCR registers, such that code exporting the GIC diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 9270cd87da3f..a0be53bc5703 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -263,7 +263,7 @@ struct vgic_dist { struct vgic_io_device dist_iodev; bool has_its; - bool save_its_tables_in_progress; + bool save_tables_in_progress; /* * Contains the attributes and gpa of the LPI configuration table. From patchwork Thu Jan 26 23:54:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 48979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp554011wrn; Thu, 26 Jan 2023 16:03:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/7JHkVoblv8ZWq+SJz30FEhbSKyUHXbXTPAyElSjOAH4+qFSIi2qQ5yA8+mCtQKa4tfiW X-Received: by 2002:a05:6402:2315:b0:49e:6a70:d9a6 with SMTP id l21-20020a056402231500b0049e6a70d9a6mr28110415eda.25.1674777782616; Thu, 26 Jan 2023 16:03:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674777782; cv=none; d=google.com; s=arc-20160816; b=0xkyvNeBMsXYerXh0EnmUCcl/FCQKyGqREcW8FFAvVbjCW/vhgHfLVCzC4porzBmM7 W82A623aA/DKGPO3ZPyvYS4dtCEYVz04Uz0V6m1ny3NyZAXCoViigxrK3yGOOxL6sMn2 tGKH4PZ0GcKUyZTIPpkD8crzMkGE1ESEzFpT5xuisR2d5WnbHqYJ//3wWetghNcFrJ0q tMNLruWft99Ctg30T628TnKRgGJY8scC06FOvc7QmmLFnS72bX4cPzizZ8YloGxKDQ3v G8DmrbR4gSmrYX1Szcx8v9nY9e2o4J3Nlfg8V+vYQVfBalcWvICpEwIMECuJ6/J0PH9/ 7Rpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v0k2LdruntFpx2ttdih4bIPnTl7L9WM09WTVFT9+2zo=; b=o2fbVeplS4gaIJVOKx4cRPQevjIcxCnEmy8+kHF06WP8v8+TeybmCHr5VGyVmo9Rlg +zNQFSssPaxeehFpSAqT4WQFy+Q+TyT1uZfYxdc0k0oZ+pz2EIjD57nUOzlySlWlOKOI xiXna++52XvpR/+9ERpXp4+EmUZ/CUMuISDTGJOFnjzr5w2w7yjy4rso/JOzdMxRsno+ ILF5D58Ut3q1R2tWPLiHUbsyMuv5MLcx07mlY8vrhQxurKh5xlfvONLP5FNULd2CwocB NsaQe29XpJ36W/LCQS0Q3iKfGkVUnCeVqOPGGNOBK5Bpi4pz3Ky8hf0IJ7DgOsQxqFT7 vUIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OjNmufZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170906019100b0087124db83a3si2601551ejb.880.2023.01.26.16.02.38; Thu, 26 Jan 2023 16:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OjNmufZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233598AbjAZX4a (ORCPT + 99 others); Thu, 26 Jan 2023 18:56:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233321AbjAZX41 (ORCPT ); Thu, 26 Jan 2023 18:56:27 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AB534CE4E for ; Thu, 26 Jan 2023 15:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674777336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v0k2LdruntFpx2ttdih4bIPnTl7L9WM09WTVFT9+2zo=; b=OjNmufZ053qBzYVZgm2SF+9dHV9ohFQp6Y9OgwUiqJzJiyTVjL/Ef9dtMPmW8J/+JsdMZ1 IOeq6AE9OJ0xnrPvr8equOMntluO0CGDH5ewzfB0E/ButktTY23bCAww3VO9nWvdsij500 1kKD9JhlV7CpYM1nVZ56S1vmiculsG8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-iM7GUvV8N3iESEj2vdfZOQ-1; Thu, 26 Jan 2023 18:55:30 -0500 X-MC-Unique: iM7GUvV8N3iESEj2vdfZOQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AA8618811F6; Thu, 26 Jan 2023 23:55:29 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-98.bne.redhat.com [10.64.54.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8E6D2166B26; Thu, 26 Jan 2023 23:55:21 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.linux.dev Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yuzhe@nfschina.com, isaku.yamahata@intel.com, seanjc@google.com, ricarkol@google.com, eric.auger@redhat.com, renzhengeek@gmail.com, reijiw@google.com, shan.gavin@gmail.com Subject: [PATCH v3 3/4] KVM: arm64: Allow no running vcpu on restoring vgic3 LPI pending status Date: Fri, 27 Jan 2023 07:54:50 +0800 Message-Id: <20230126235451.469087-4-gshan@redhat.com> In-Reply-To: <20230126235451.469087-1-gshan@redhat.com> References: <20230126235451.469087-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756131787953774463?= X-GMAIL-MSGID: =?utf-8?q?1756131787953774463?= We don't have a running VCPU context to restore vgic3 LPI pending status due to command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device "kvm-arm-vgic-its". Use vgic_write_guest_lock() to restore vgic3 LPI pending status. Signed-off-by: Gavin Shan Reviewed-by: Oliver Upton --- Documentation/virt/kvm/api.rst | 8 +++++--- arch/arm64/kvm/vgic/vgic-v3.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 9807b05a1b57..40ada313faa3 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8070,9 +8070,11 @@ considering the state as complete. VMM needs to ensure that the dirty state is final and avoid missing dirty pages from another ioctl ordered after the bitmap collection. -NOTE: One example of using the backup bitmap is saving arm64 vgic/its -tables through KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} command on -KVM device "kvm-arm-vgic-its" when dirty ring is enabled. +NOTE: Multiple examples of using the backup bitmap: (1) save vgic/its +tables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} on +KVM device "kvm-arm-vgic-its". (2) restore vgic/its tables through +command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device +"kvm-arm-vgic-its". vgic3 LPI pending status is restored. 8.30 KVM_CAP_XEN_HVM -------------------- diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 5dfbd03e5e1a..c94e4d7520fc 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -338,7 +338,7 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq) if (status) { /* clear consumed data */ val &= ~(1 << bit_nr); - ret = kvm_write_guest_lock(kvm, ptr, &val, 1); + ret = vgic_write_guest_lock(kvm, ptr, &val, 1); if (ret) return ret; } From patchwork Thu Jan 26 23:54:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 48978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553205wrn; Thu, 26 Jan 2023 16:01:26 -0800 (PST) X-Google-Smtp-Source: AK7set9uqa3ORP7nid2FfMWJEUFiF5ojcgVYcJ2euCJa2Z6Z/U5JfMfSOB5ugmT4Ebah/1TsR4LE X-Received: by 2002:a17:906:a411:b0:878:72f7:bd87 with SMTP id l17-20020a170906a41100b0087872f7bd87mr3190074ejz.6.1674777686665; Thu, 26 Jan 2023 16:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674777686; cv=none; d=google.com; s=arc-20160816; b=nkerOGHbTp650CY5apHbDzMX9Z8O+qwbC7edmCQ1VbGLgjcAx5+VLWIjbfTVFQ5L+s dw3uf0O2sf0NxPA/krXcZb7wPfor5arGrrn6dtb7HgrPbNyQ5AMKSSUFQ4zg64/+KjKM JLGTqHlnzCZj6B5N/w0keJbCOLhG1TngFnEeg/EfcLnFvqU6h4rSnGouyrLH9VVSVkue ygAEy173xaEKH8wf+uesMfUj7unC/9Cn8ePUyjHpzgD1dShbq/J9DREy2ko+tIJmggvv rLr6wLK6isU/6MbHCBno7aPUdQwnuIU6dSR/adSyESkjLRfQ1Us5BJmn3F1xGQK9NyVx x0Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=898ohfdzehorjeXOEBd+HSoOXx0TlEdaod7Ot+z55Ec=; b=rCsyAsb4DC4jTxNuBBLrloos+4KCwCqxPIUlzy4zpU2E1h+Ggtj4YGUcHni2XIfcbO cgi2WhkVbxBI39qMRCYOIGAvbSMJQUdqaNg8ScDHlu2ncc/+iQOxBukE4vvz4x2Jf3th 2EO/8Xn4FfwLBw8dV7qUoPbnN0kPyG1z1HCGwvb8fRXjJrxNkLwqdbP3mq+SrRpvspqG 3GyGKgHsqA60okASNSZ5190YxtCjrZ+GXLAIu6HDQg9zEVpT3fFAI02RMHsYDZFWf57L kH8qulbwNtgatHx24CP0yQnsEIvUt1nYWvFct7DEJ0wpLqPCc3B/lnJkhPRktcQILfmy 24Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kpzq1e7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a509b45000000b0049e2ac8d02fsi4149654edj.569.2023.01.26.16.01.01; Thu, 26 Jan 2023 16:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kpzq1e7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233030AbjAZX4h (ORCPT + 99 others); Thu, 26 Jan 2023 18:56:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbjAZX4d (ORCPT ); Thu, 26 Jan 2023 18:56:33 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D70044BCC for ; Thu, 26 Jan 2023 15:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674777343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=898ohfdzehorjeXOEBd+HSoOXx0TlEdaod7Ot+z55Ec=; b=Kpzq1e7AR87RRImg/ms868pwPT1j8ZrusOyL4h6v8P2HQwdSDBD6k4cw+y+KYsTTCbcpdq gJxQHvvSvRMgeTG/HRTKKfcP/ijgnsL7OLravGBjH1t2I2JeG+tvICsJVnFp4t4IRK0swb 0rzerYW+Xmcs6WAm6sVqOR80oj2y/kI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-84-G0DpR1_uM622mmKCTiCNqA-1; Thu, 26 Jan 2023 18:55:38 -0500 X-MC-Unique: G0DpR1_uM622mmKCTiCNqA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33154858F09; Thu, 26 Jan 2023 23:55:37 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-98.bne.redhat.com [10.64.54.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCD692166B26; Thu, 26 Jan 2023 23:55:29 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.linux.dev Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yuzhe@nfschina.com, isaku.yamahata@intel.com, seanjc@google.com, ricarkol@google.com, eric.auger@redhat.com, renzhengeek@gmail.com, reijiw@google.com, shan.gavin@gmail.com Subject: [PATCH v3 4/4] KVM: arm64: Allow no running vcpu on saving vgic3 pending table Date: Fri, 27 Jan 2023 07:54:51 +0800 Message-Id: <20230126235451.469087-5-gshan@redhat.com> In-Reply-To: <20230126235451.469087-1-gshan@redhat.com> References: <20230126235451.469087-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756131687697826190?= X-GMAIL-MSGID: =?utf-8?q?1756131687697826190?= We don't have a running VCPU context to save vgic3 pending table due to KVM_DEV_ARM_VGIC_{GRP_CTRL, SAVE_PENDING_TABLES} command on KVM device "kvm-arm-vgic-v3". The unknown case is caught by kvm-unit-tests. # ./kvm-unit-tests/tests/its-pending-migration WARNING: CPU: 120 PID: 7973 at arch/arm64/kvm/../../../virt/kvm/kvm_main.c:3325 \ mark_page_dirty_in_slot+0x60/0xe0 : mark_page_dirty_in_slot+0x60/0xe0 __kvm_write_guest_page+0xcc/0x100 kvm_write_guest+0x7c/0xb0 vgic_v3_save_pending_tables+0x148/0x2a0 vgic_set_common_attr+0x158/0x240 vgic_v3_set_attr+0x4c/0x5c kvm_device_ioctl+0x100/0x160 __arm64_sys_ioctl+0xa8/0xf0 invoke_syscall.constprop.0+0x7c/0xd0 el0_svc_common.constprop.0+0x144/0x160 do_el0_svc+0x34/0x60 el0_svc+0x3c/0x1a0 el0t_64_sync_handler+0xb4/0x130 el0t_64_sync+0x178/0x17c Use vgic_write_guest_lock() to save vgic3 pending table. Reported-by: Zenghui Yu Signed-off-by: Gavin Shan Reviewed-by: Oliver Upton --- Documentation/virt/kvm/api.rst | 4 +++- arch/arm64/kvm/vgic/vgic-v3.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 40ada313faa3..07f07668995e 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8074,7 +8074,9 @@ NOTE: Multiple examples of using the backup bitmap: (1) save vgic/its tables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} on KVM device "kvm-arm-vgic-its". (2) restore vgic/its tables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device -"kvm-arm-vgic-its". vgic3 LPI pending status is restored. +"kvm-arm-vgic-its". vgic3 LPI pending status is restored. (3) save +vgic3 pending table through KVM_DEV_ARM_VGIC_{GRP_CTRL, SAVE_PENDING_TABLES} +command on KVM device "kvm-arm-vgic-v3". 8.30 KVM_CAP_XEN_HVM -------------------- diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index c94e4d7520fc..558ccc805fff 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -436,7 +436,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm) else val &= ~(1 << bit_nr); - ret = kvm_write_guest_lock(kvm, ptr, &val, 1); + ret = vgic_write_guest_lock(kvm, ptr, &val, 1); if (ret) goto out; }