From patchwork Sat Sep 16 00:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6716CD37AF for ; Sat, 16 Sep 2023 00:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hk5Xbfssq/TVIZq5QxHRnCcyYYrrTIjR0qzCR4ziLkA=; b=kEsE62sD4kcP8p /NefhgMtO015zgNZbhFRRcE0jnENdW+iQxDXqinzIS24eAjJpH/oGhrBkI2JH/BWSn+CwSYwKkRF1 BwEgJdgwgckl6JTwPL14AHrZEFn03bSnhkdedXiAD8GOk3pxuNwfUdETZbfUWKOoz6Br+f/FNDiTG ce9Yt4fhK3R68E2F2vlIzRmuLMLDUN36hfVv3pplHVP1WvJ0ESH/rJJjZizm3dhdhmwytUNGbIpxr quapx27H58z02vhYFo/8zVXE+VL+BPQMrmZ9XeO7diBXhp7M+u1U0DHYgNk0v1K4lTemCqN0mIfZJ 84TScaYZyow5/0XxdP6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDe-00BcSy-32; Sat, 16 Sep 2023 00:31:30 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDa-00BcMo-27 for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:29 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b50b45481so34126547b3.1 for ; Fri, 15 Sep 2023 17:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824283; x=1695429083; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=CcWcgzjI/Sjr3SKdjnMS4CWAtaq/GpOs1NzqJV8HV48=; b=FYBuZ5fv+xw1oDV1tu9yPyM8sUVk9+f1yXuKbNlo1sQE1P7c1MS3zZKhVswyrJs2kR FkEq4d+MZeOlaMBwiiqh+GqG+TOCL269DunUZ4mDHZb5SxFMiw5o0XBM2JCRCdkSGXpi gDeq1BW1gBYsJD5xvj5J+zc+y9/eP1abH+14bfb4ndxfRmrSK/K3/giWDmALL2PYCS4i LPY4IbCYc5IH7BIPRYPy/TL6st0KeM+61d7YhwrD6k6STAxGKpt1FyURFb4hCQ+qq19i 1NV6C2wut/rkacQOBtcfA0yTSQAqirp/AGMFq7K/MmDGmKvfTcUAo+GhpLInCsq8iIuN QQ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824283; x=1695429083; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CcWcgzjI/Sjr3SKdjnMS4CWAtaq/GpOs1NzqJV8HV48=; b=wi1uOeV9MEaoeuy2Bnid8maAUxJIPcHPMpa/7O7nPmnZVbfp57uHnX+zL75dHulrPy OA0HW5mUg/f2MQFYel1zj45QyxS0Qy3nVPJfeGlVBmL4O76XrCq8/lFbqlQhjoU0ABst XIObUap0iCRmlaV1PptsAm/oeu+XffqIALYHLPsboYGSOB7JrFX0nYz3/keFt06IGw/q lgGnInzjjxjC+dmQnrXjzn4UtrTQDQWNoHKqf9i4R6nTRiq8PYmpvgk9VonXY2p5N1r1 IO6iLNwtW31RZM7eOOV+m4fdYSGJePZas60xQVXik3+6Y1EUI6kSchDhPrfO8Yw0zv8b /TVg== X-Gm-Message-State: AOJu0YxP0DSWiOtfBc8m1hSPGkN8VZ+WdILLwiq+esjcHsHZF1Dpubux c3oZF5aDARLf2Yn1l1FiGBQK30SNCWc= X-Google-Smtp-Source: AGHT+IEjplB8N3p+oR/7zKlMcxL9iCUBmO4vshw551ibG3RHlQehJcUKg5dHZyrgSIjo7xUVmV5xBYFOkj8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b612:0:b0:565:9bee:22e0 with SMTP id u18-20020a81b612000000b005659bee22e0mr85362ywh.0.1694824282871; Fri, 15 Sep 2023 17:31:22 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:53 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-2-seanjc@google.com> Subject: [PATCH 01/26] vfio: Wrap KVM helpers with CONFIG_KVM instead of CONFIG_HAVE_KVM From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173126_694187_B775E423 X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Wrap the helpers for getting references to KVM instances with a check on CONFIG_KVM being enabled, not on CONFIG_HAVE_KVM being defined. PPC does NOT select HAVE_KVM, despite obviously supporting KVM, and guarding code to get references to KVM based on whether or not the architecture supports KVM is nonsensical. Drop the guard around linux/kvm_host.h entirely, conditionally including a generic headers is completely unnecessary. Signed-off-by: Sean Christopherson Reviewed-by: Jason Gunthorpe Reviewed-by: Alex Williamson --- drivers/vfio/vfio.h | 2 +- drivers/vfio/vfio_main.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index 307e3f29b527..c26d1ad68105 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -434,7 +434,7 @@ static inline void vfio_virqfd_exit(void) } #endif -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm); void vfio_device_put_kvm(struct vfio_device *device); #else diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 40732e8ed4c6..80e39f7a6d8f 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -16,9 +16,7 @@ #include #include #include -#ifdef CONFIG_HAVE_KVM #include -#endif #include #include #include @@ -383,7 +381,7 @@ void vfio_unregister_group_dev(struct vfio_device *device) } EXPORT_SYMBOL_GPL(vfio_unregister_group_dev); -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm) { void (*pfn)(struct kvm *kvm); From patchwork Sat Sep 16 00:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEEA9CD37AF for ; Sat, 16 Sep 2023 00:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9XaYO7TDqMW0ev6kFNmAlgFj7VDNZLLIs2WYIKP2a3g=; b=i5+MGNmwzVm2Xr wc9v+JTFWxPqOCxeW1IqBL9gkp/2iFb/mG5sCKduxj2/jNcngbap00N/8alXCyU8x1a52F6EQL2rU eBUDEoYbZ5oSwrvGnr6D+hNq5T649aio3+h1xyBpVoFnRQcYy4Kf07pIa6BnzUkD9+4JeONYLEGId 0L9AWrY9EiLphc5vNRQO777lfLcLYPo6t4LP7HYUMnOrVvbs7s67VWuVAsLq1fnLKSJxH0sN5/U/A w+1jOkaiI9uY6cBTesU3KdIAHrZzG4QYRvrV3cESNKqBsRE1YYYNYwSM2qk2beZYpUPbBPGuTq2PK eY4XaSHsvuHcYSm4IQVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDq-00Bcem-12; Sat, 16 Sep 2023 00:31:42 +0000 Received: from mail-oa1-x4a.google.com ([2001:4860:4864:20::4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDb-00BcNA-0c for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:31 +0000 Received: by mail-oa1-x4a.google.com with SMTP id 586e51a60fabf-1b728bfb372so4416338fac.2 for ; Fri, 15 Sep 2023 17:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824284; x=1695429084; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=NdOAPx70WjWtTXOKtIxgwEtN+XJRELer/ruyZoFwPzQ=; b=LSquUboBDoQ7KX4y/WPTLIPUsaCl72dhIc0X/rKkpVaRLs7PKmbtHjA4s7bh+zaMCV eqYI2syT9HFV5iKs76v6cXfEDFW01sNZWGOuhis1vIXp+5Bg6AtKNDBEgAwLvKxeU1Pp xIo6aBZ7VwKqOPO2qeTk1EW9e5InPNGysEmmS67t5Woque/ViGY1loxGQ+zFXEm9suzK DuVgEzB9puF7k819xSf4xlm5TVVl4xwAd6iyyVaCvz3K6CHxmXCnDV6XSuRUskS2Eoli 8elzgoJLg1LZilp32721lIEm9G1gU8Ygmd+UYm5tvp0GyMzoooBvdOSBmyAoQ4gzToss 1lHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824284; x=1695429084; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NdOAPx70WjWtTXOKtIxgwEtN+XJRELer/ruyZoFwPzQ=; b=fSrJqsv5jKIenFvDmoFUJFSV+cXhf9V2A67tL8A6IRRepA323x7ZWHjJ+77/77fd6i dz4tqv1k4T1sp9qkUrlbpckNpDZXHwhDSVfF8evWa6UvA5KltQCeiIwdcw0gDo24J8E3 ZodIvyLCGBGiLbwAc3PBQ/nLXK9yeUVaYnO0eUSibTid2eeRTqjtLI3XfVP6sG67Hhjj PN/mGoUOE0IE+143WUXResUiKHfCHua64wKAkOdC5vsmxUF8SME6urPGcxeDGq6te7v0 Iqs6t8pB8RO7R0fiimdwsz9SUrRXainNYKfG7yLwvjh1WSaNOEqKFL5Ap9z+g8/DjajL KIhg== X-Gm-Message-State: AOJu0Yw7ltq6SkvV6xD7jHaAzxcNhXE48xiVGNavJ/1QpWXQbSyFweyO euNHZXEumvd4sL8L0HdWpkQumhiazXo= X-Google-Smtp-Source: AGHT+IFjfayrLbVmI/uUcITF7riix4t2p7LQSznFwYgaB2xPw0hEc6MrZUjOPPPKeYuL02E3L+TxPOZWHW4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6870:b7ad:b0:1d6:4da3:ae2d with SMTP id ed45-20020a056870b7ad00b001d64da3ae2dmr1068876oab.7.1694824284654; Fri, 15 Sep 2023 17:31:24 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:54 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-3-seanjc@google.com> Subject: [PATCH 02/26] vfio: Move KVM get/put helpers to colocate it with other KVM related code From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173127_270835_DFE37DB3 X-CRM114-Status: GOOD ( 12.75 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move the definitions of vfio_device_get_kvm_safe() and vfio_device_put_kvm() down in vfio_main.c to colocate them with other KVM-specific functions, e.g. to allow wrapping them all with a single CONFIG_KVM check. Signed-off-by: Sean Christopherson Reviewed-by: Jason Gunthorpe Reviewed-by: Alex Williamson --- drivers/vfio/vfio_main.c | 104 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 80e39f7a6d8f..6368eed7b7b2 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -381,58 +381,6 @@ void vfio_unregister_group_dev(struct vfio_device *device) } EXPORT_SYMBOL_GPL(vfio_unregister_group_dev); -#if IS_ENABLED(CONFIG_KVM) -void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm) -{ - void (*pfn)(struct kvm *kvm); - bool (*fn)(struct kvm *kvm); - bool ret; - - lockdep_assert_held(&device->dev_set->lock); - - if (!kvm) - return; - - pfn = symbol_get(kvm_put_kvm); - if (WARN_ON(!pfn)) - return; - - fn = symbol_get(kvm_get_kvm_safe); - if (WARN_ON(!fn)) { - symbol_put(kvm_put_kvm); - return; - } - - ret = fn(kvm); - symbol_put(kvm_get_kvm_safe); - if (!ret) { - symbol_put(kvm_put_kvm); - return; - } - - device->put_kvm = pfn; - device->kvm = kvm; -} - -void vfio_device_put_kvm(struct vfio_device *device) -{ - lockdep_assert_held(&device->dev_set->lock); - - if (!device->kvm) - return; - - if (WARN_ON(!device->put_kvm)) - goto clear; - - device->put_kvm(device->kvm); - device->put_kvm = NULL; - symbol_put(kvm_put_kvm); - -clear: - device->kvm = NULL; -} -#endif - /* true if the vfio_device has open_device() called but not close_device() */ static bool vfio_assert_device_open(struct vfio_device *device) { @@ -1354,6 +1302,58 @@ bool vfio_file_enforced_coherent(struct file *file) } EXPORT_SYMBOL_GPL(vfio_file_enforced_coherent); +#if IS_ENABLED(CONFIG_KVM) +void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm) +{ + void (*pfn)(struct kvm *kvm); + bool (*fn)(struct kvm *kvm); + bool ret; + + lockdep_assert_held(&device->dev_set->lock); + + if (!kvm) + return; + + pfn = symbol_get(kvm_put_kvm); + if (WARN_ON(!pfn)) + return; + + fn = symbol_get(kvm_get_kvm_safe); + if (WARN_ON(!fn)) { + symbol_put(kvm_put_kvm); + return; + } + + ret = fn(kvm); + symbol_put(kvm_get_kvm_safe); + if (!ret) { + symbol_put(kvm_put_kvm); + return; + } + + device->put_kvm = pfn; + device->kvm = kvm; +} + +void vfio_device_put_kvm(struct vfio_device *device) +{ + lockdep_assert_held(&device->dev_set->lock); + + if (!device->kvm) + return; + + if (WARN_ON(!device->put_kvm)) + goto clear; + + device->put_kvm(device->kvm); + device->put_kvm = NULL; + symbol_put(kvm_put_kvm); + +clear: + device->kvm = NULL; +} +#endif + static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) { struct vfio_device_file *df = file->private_data; From patchwork Sat Sep 16 00:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE498CD37B0 for ; Sat, 16 Sep 2023 00:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p3EYwMzYOmIeNCk0OI/ChKSZg4TfMVj8gk447r89wmQ=; b=CloCUf6EfW4Q17 B6N99+vS/IlvwkwkiEgRAHib2DivIdHHfAJMINzBDMkKh3QFT8eJMv3g3nh5Vj4AHW9pcNVRs4NWN ZhZ8eH8RYSSZLdeGECRdcvHvwskbcRNcA+q1p5rRcdB10c7aLgbW/xPfvk/MLEWsLSUfFkGPXYUf/ OlVWxOoKgXZGDSxa/InP4PL+unFsIvfzDrgEU16I+YXBkE4/Uiie3cgmUMY18iwQjAixV/pj9KXLk DBKcWBeBCZGjp/cOJISRmAi1R5LugK6B8pPQw/YQoaxxGRL2gJjIkfi98P32o/rotuK1H9F1xA6Jk EY1Xt7vuNaz1KDpYW+rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDn-00Bcbj-30; Sat, 16 Sep 2023 00:31:39 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDb-00BcOy-2z for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:31 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d81ff714678so834576276.2 for ; Fri, 15 Sep 2023 17:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824286; x=1695429086; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=nWWn+h7amRZMBDw3vQNPHGAGWvxVaFdsCPW0ONMozkY=; b=Au/whQJEbAz+tOQ0jTzYnTHaUFqhk5Pgnrngt42R++heKHXOJ2U0YqnWh0A650p1pa PgbaR8YETO7ZKMYj3h4ONGnm912OY1X6nLqjUcHYZw2SCfppPlE9QI2MsrQBEt75JnUC id4P01cAv4bW2aLSS66YB0WfN9NrUSsO4HoyRU+POe5EIZ7yVc+3t4OXLj8PN8fDq6JE c1c2P6OXojAgG+hgLNLnSW9HWM9GkahkdPQXAfN7FUfYqpv0WvPKm9erEu/ZABleqTqp zYfI7WBh8dzi1TGBAWipfQzZdZFRePBIBZjwqD125053Cb0+8X4DsgJKIjfE45v20PE2 j8FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824286; x=1695429086; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nWWn+h7amRZMBDw3vQNPHGAGWvxVaFdsCPW0ONMozkY=; b=tznPA9omB0kneW2aRClyk8DeXKmTqTC9vxeTgnOcsiHuMtsLEIo8iIHRC3c8ZZ4O42 O0VHaJGEJXGALTWEOsAQud+eYklQnLKytChZT60osqo8H32w1eC8CSi37D+fm+TMr2Sh DpTjDDrryNjUVOr0IXnfiRfXgaaPW1JKXnLYFMwDdy+17CvX8s6jOohZBItRChgXSxvH aO3qKivgkpmGwZo9wIG06OrRCbpynO/8jlUxr821n1SbHEjEX+lYBD6oEAnwxSXkrqA/ s4AmadXBkBpKeTvX3MdpcmKwW5V/mN2OEpQGqOHRIjg2OPA8VK+UofGPa+rYs9TGQasZ Ynsg== X-Gm-Message-State: AOJu0YyTQDBJ7pPvPfDYUTxvXv+gsuL6pe/YFfLJgb3f+tpmVzIGksVu XBLmMaZl8ti0znFiulY2dmoy9Lrkzvo= X-Google-Smtp-Source: AGHT+IEq7PdKxRZn76T8dxJekIJKystQKt2vwlGFVVGJbIP+fTzk72beaUliTqaKSj/nh0feFGYdLVI2swc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:98b:b0:d81:5948:970 with SMTP id bv11-20020a056902098b00b00d8159480970mr72987ybb.13.1694824286666; Fri, 15 Sep 2023 17:31:26 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:55 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-4-seanjc@google.com> Subject: [PATCH 03/26] virt: Declare and define vfio_file_set_kvm() iff CONFIG_KVM is enabled From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173127_983667_1272D81D X-CRM114-Status: GOOD ( 11.95 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Hide vfio_file_set_kvm() and its unique helpers if KVM is not enabled, nothing else in the kernel (or out of the kernel) should be using a KVM specific helper. Signed-off-by: Sean Christopherson Reviewed-by: Jason Gunthorpe Reviewed-by: Alex Williamson --- drivers/vfio/vfio_main.c | 2 +- include/linux/vfio.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 6368eed7b7b2..124cc88966a7 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -1352,7 +1352,6 @@ void vfio_device_put_kvm(struct vfio_device *device) clear: device->kvm = NULL; } -#endif static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) { @@ -1388,6 +1387,7 @@ void vfio_file_set_kvm(struct file *file, struct kvm *kvm) vfio_device_file_set_kvm(file, kvm); } EXPORT_SYMBOL_GPL(vfio_file_set_kvm); +#endif /* * Sub-module support diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 454e9295970c..e80955de266c 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -311,7 +311,9 @@ static inline bool vfio_file_has_dev(struct file *file, struct vfio_device *devi #endif bool vfio_file_is_valid(struct file *file); bool vfio_file_enforced_coherent(struct file *file); +#if IS_ENABLED(CONFIG_KVM) void vfio_file_set_kvm(struct file *file, struct kvm *kvm); +#endif #define VFIO_PIN_PAGES_MAX_ENTRIES (PAGE_SIZE/sizeof(unsigned long)) From patchwork Sat Sep 16 00:30:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 929CDCD37B0 for ; Sat, 16 Sep 2023 01:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nj2fdQy8WYdjxzr1ZUJD3r94wz8n/DLNEVGpinrhlqk=; b=hBGQhgtydUByg4 qEdEeObMRN8ImHsACZ2keBmCvn30xAO8H4ZvugIoWyq/pzVuNu6q+8sNBywSoAvChvUeHnx+5OLF3 H9Dhl93AegHSnATQx81tGCcTigt7icJyy2chdP61skyAo96g+BPNW+wbgZUxqzSaLpOCMnN8+L/ct dJB6JUSpnLICLvAqbMG/YokuOTJcVRzuoP0ptMAqtYD7GZy0XKwzPmwUkRyv8Md9hO+XRjb947glk /kCm6GmV6Cr5/V1DyQQl/vsUH8cd33FoPVyEBN2t2hT4zYoonMFtf1N2JdWahKIRNVqb2gRICLN1N E4sU5JDtcvD6RlBPQg2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhKNq-00BkJO-0G; Sat, 16 Sep 2023 01:46:06 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDe-00BcRf-1H for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:36 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d7e79ec07b4so3171301276.0 for ; Fri, 15 Sep 2023 17:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824289; x=1695429089; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=XNfaWnR713DgNOXX6oC0phI1nRzZDxqQCByPnT54704=; b=vxxuhdul9xo2nGLb9KoiBumXP3cVlNjnYREwcmcNFURvUHLHcf0REESba1INUbT67R TJ7gLsQBJ4F/lt7AiT/xBDMjnFMhl83dqLIPeaoLgsFk8d8YXwZR41v2iImfMR486eIz 1gRmxT4KzayJW2Cg5+kYLrH0t5mGgFCVDlSPTlfkuUNrL9z4itEgTO0t19J3julpnn2S JbhAwy0bl7ueuedl1GAKH4i3NL9hCYvzgg+0QjRMgdO3riAqHP8jMJplwoBNiOzsxTbp iH8WM3GCg/O63wW44VMIpVBSTwq+ypAyYp9G/naeGsIxbRG2DqvBxQHdeiN2QeDOXGGr BHZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824289; x=1695429089; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XNfaWnR713DgNOXX6oC0phI1nRzZDxqQCByPnT54704=; b=Qd76zXBl4pxvNUqDZKxIflXZLnPBwqOBTWzPyJDOrWEhK7B6h4LWFizYn1nHjnSYD1 8gVzz4nuerXPyuHhHwP3kp/bXv5SM7fhSN/+ZiG+5h4BNKC3zwY39hlybsBsHT8Y00Wt AY96d/XYSBUZU7KrZGilquurNa4hYZaj6x/wwZpn/6ltvsiUYEFNhoeick/bg3W4xiLh qo3eqMY7OKRp09svJ4hpl/MIzhkX+Lbsw7xt3+8jz8uBYlgAu4TTw3u+PkKieWvOjC9j iX8iqhzk+3u2Oer7p9lcs6Ic92rhix71V4sD7hYynuIgSMizQUGulwsrsdQW1Ccj/nVP xaYA== X-Gm-Message-State: AOJu0YzOjMCz7EvxYmK+xDJLMH1CWa30b02yIAA7+THOZItZnYxOwanK HnC5B0bArKYL3vCCiBfkbG7EyGwgQrE= X-Google-Smtp-Source: AGHT+IGvtU4vAL07Ep1DYBA3eTFA34U05IWJGHx1Y/tLzKqZb8SnlC6/6SqqxeE2xQbrWfOJDU/nK++52MU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:d856:0:b0:d13:856b:c10a with SMTP id p83-20020a25d856000000b00d13856bc10amr78847ybg.3.1694824288887; Fri, 15 Sep 2023 17:31:28 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:56 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-5-seanjc@google.com> Subject: [PATCH 04/26] vfio: Add struct to hold KVM assets and dedup group vs. iommufd code From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173130_479007_9E0EECD0 X-CRM114-Status: GOOD ( 21.93 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add a struct to hold the KVM assets need to manage and pass along KVM references to VFIO devices. Providing a common struct deduplicates the group vs. iommufd code, and will make it easier to rework the attachment logic so that VFIO doesn't have to do a symbol lookup to retrieve the get/put helpers from KVM. Signed-off-by: Sean Christopherson Reviewed-by: Alex Williamson --- drivers/vfio/device_cdev.c | 9 +------- drivers/vfio/group.c | 18 ++-------------- drivers/vfio/vfio.h | 22 +++++++++---------- drivers/vfio/vfio_main.c | 43 +++++++++++++++++++++++++++----------- 4 files changed, 45 insertions(+), 47 deletions(-) diff --git a/drivers/vfio/device_cdev.c b/drivers/vfio/device_cdev.c index e75da0a70d1f..e484d6d6400a 100644 --- a/drivers/vfio/device_cdev.c +++ b/drivers/vfio/device_cdev.c @@ -46,13 +46,6 @@ int vfio_device_fops_cdev_open(struct inode *inode, struct file *filep) return ret; } -static void vfio_df_get_kvm_safe(struct vfio_device_file *df) -{ - spin_lock(&df->kvm_ref_lock); - vfio_device_get_kvm_safe(df->device, df->kvm); - spin_unlock(&df->kvm_ref_lock); -} - long vfio_df_ioctl_bind_iommufd(struct vfio_device_file *df, struct vfio_device_bind_iommufd __user *arg) { @@ -99,7 +92,7 @@ long vfio_df_ioctl_bind_iommufd(struct vfio_device_file *df, * a reference. This reference is held until device closed. * Save the pointer in the device for use by drivers. */ - vfio_df_get_kvm_safe(df); + vfio_device_get_kvm_safe(df->device, &df->kvm_ref); ret = vfio_df_open(df); if (ret) diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c index 610a429c6191..756e47ff4cf0 100644 --- a/drivers/vfio/group.c +++ b/drivers/vfio/group.c @@ -157,13 +157,6 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, return ret; } -static void vfio_device_group_get_kvm_safe(struct vfio_device *device) -{ - spin_lock(&device->group->kvm_ref_lock); - vfio_device_get_kvm_safe(device, device->group->kvm); - spin_unlock(&device->group->kvm_ref_lock); -} - static int vfio_df_group_open(struct vfio_device_file *df) { struct vfio_device *device = df->device; @@ -184,7 +177,7 @@ static int vfio_df_group_open(struct vfio_device_file *df) * the pointer in the device for use by drivers. */ if (device->open_count == 0) - vfio_device_group_get_kvm_safe(device); + vfio_device_get_kvm_safe(device, &device->group->kvm_ref); df->iommufd = device->group->iommufd; if (df->iommufd && vfio_device_is_noiommu(device) && device->open_count == 0) { @@ -560,7 +553,7 @@ static struct vfio_group *vfio_group_alloc(struct iommu_group *iommu_group, refcount_set(&group->drivers, 1); mutex_init(&group->group_lock); - spin_lock_init(&group->kvm_ref_lock); + spin_lock_init(&group->kvm_ref.lock); INIT_LIST_HEAD(&group->device_list); mutex_init(&group->device_lock); group->iommu_group = iommu_group; @@ -884,13 +877,6 @@ bool vfio_group_enforced_coherent(struct vfio_group *group) return ret; } -void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm) -{ - spin_lock(&group->kvm_ref_lock); - group->kvm = kvm; - spin_unlock(&group->kvm_ref_lock); -} - /** * vfio_file_has_dev - True if the VFIO file is a handle for device * @file: VFIO file to check diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index c26d1ad68105..a1f741365075 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -12,18 +12,23 @@ #include #include +struct kvm; struct iommufd_ctx; struct iommu_group; struct vfio_container; +struct vfio_kvm_reference { + struct kvm *kvm; + spinlock_t lock; +}; + struct vfio_device_file { struct vfio_device *device; struct vfio_group *group; u8 access_granted; u32 devid; /* only valid when iommufd is valid */ - spinlock_t kvm_ref_lock; /* protect kvm field */ - struct kvm *kvm; + struct vfio_kvm_reference kvm_ref; struct iommufd_ctx *iommufd; /* protected by struct vfio_device_set::lock */ }; @@ -88,11 +93,10 @@ struct vfio_group { #endif enum vfio_group_type type; struct mutex group_lock; - struct kvm *kvm; + struct vfio_kvm_reference kvm_ref; struct file *opened_file; struct blocking_notifier_head notifier; struct iommufd_ctx *iommufd; - spinlock_t kvm_ref_lock; unsigned int cdev_device_open_cnt; }; @@ -108,7 +112,6 @@ void vfio_device_group_unuse_iommu(struct vfio_device *device); void vfio_df_group_close(struct vfio_device_file *df); struct vfio_group *vfio_group_from_file(struct file *file); bool vfio_group_enforced_coherent(struct vfio_group *group); -void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm); bool vfio_device_has_container(struct vfio_device *device); int __init vfio_group_init(void); void vfio_group_cleanup(void); @@ -171,10 +174,6 @@ static inline bool vfio_group_enforced_coherent(struct vfio_group *group) return true; } -static inline void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm) -{ -} - static inline bool vfio_device_has_container(struct vfio_device *device) { return false; @@ -435,11 +434,12 @@ static inline void vfio_virqfd_exit(void) #endif #if IS_ENABLED(CONFIG_KVM) -void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm); +void vfio_device_get_kvm_safe(struct vfio_device *device, + struct vfio_kvm_reference *ref); void vfio_device_put_kvm(struct vfio_device *device); #else static inline void vfio_device_get_kvm_safe(struct vfio_device *device, - struct kvm *kvm) + struct vfio_kvm_reference *ref) { } diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 124cc88966a7..e77e8c6aae2f 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -397,7 +397,7 @@ vfio_allocate_device_file(struct vfio_device *device) return ERR_PTR(-ENOMEM); df->device = device; - spin_lock_init(&df->kvm_ref_lock); + spin_lock_init(&df->kvm_ref.lock); return df; } @@ -1303,7 +1303,8 @@ bool vfio_file_enforced_coherent(struct file *file) EXPORT_SYMBOL_GPL(vfio_file_enforced_coherent); #if IS_ENABLED(CONFIG_KVM) -void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm) +void vfio_device_get_kvm_safe(struct vfio_device *device, + struct vfio_kvm_reference *ref) { void (*pfn)(struct kvm *kvm); bool (*fn)(struct kvm *kvm); @@ -1311,28 +1312,33 @@ void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm) lockdep_assert_held(&device->dev_set->lock); - if (!kvm) - return; + spin_lock(&ref->lock); + + if (!ref->kvm) + goto out; pfn = symbol_get(kvm_put_kvm); if (WARN_ON(!pfn)) - return; + goto out; fn = symbol_get(kvm_get_kvm_safe); if (WARN_ON(!fn)) { symbol_put(kvm_put_kvm); - return; + goto out; } - ret = fn(kvm); + ret = fn(ref->kvm); symbol_put(kvm_get_kvm_safe); if (!ret) { symbol_put(kvm_put_kvm); - return; + goto out; } device->put_kvm = pfn; - device->kvm = kvm; + device->kvm = ref->kvm; + +out: + spin_unlock(&ref->lock); } void vfio_device_put_kvm(struct vfio_device *device) @@ -1353,6 +1359,21 @@ void vfio_device_put_kvm(struct vfio_device *device) device->kvm = NULL; } +static void vfio_device_set_kvm(struct vfio_kvm_reference *ref, + struct kvm *kvm) +{ + spin_lock(&ref->lock); + ref->kvm = kvm; + spin_unlock(&ref->lock); +} + +static void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm) +{ +#if IS_ENABLED(CONFIG_VFIO_GROUP) + vfio_device_set_kvm(&group->kvm_ref, kvm); +#endif +} + static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) { struct vfio_device_file *df = file->private_data; @@ -1362,9 +1383,7 @@ static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) * be propagated to vfio_device::kvm when the file is bound to * iommufd successfully in the vfio device cdev path. */ - spin_lock(&df->kvm_ref_lock); - df->kvm = kvm; - spin_unlock(&df->kvm_ref_lock); + vfio_device_set_kvm(&df->kvm_ref, kvm); } /** From patchwork Sat Sep 16 00:30:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95C87CD37AF for ; Sat, 16 Sep 2023 00:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p6ki8UaZHm29h0TaMzmKXyCUc2V2YII7laAvNOb75Fw=; b=tcprGYpgVljtim UNjY+5L6sY1zUidreohrs3uqXCRzo6zYfOh+TFhBgfxJoXEI6IfkQ50KZOIHOA8EQYN81TILtJRz+ nY3RFLB2t0ZUq7EbjtvsRfS7tSjSrTwBm1dD4JzDq584V1SUJ1QkK9DFoCJqbsGo1FsMmKsSfUUGm zSXiqTo9UtcO8LHuOur+JygTd/8a0NX/61Oqq5eh+Mz5KzZfI/KD0ICNnA/EPtHQ4QvVazFPu/Kgx hEOwfDZczocI12flsw05FWvCo/d2U5cH9rYsYVIAHz6yMd8JEZff/vtfVihau+Zt60KeXRPheTzki xiloh6naUmABlcU7TjmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEC-00Bd3S-0Q; Sat, 16 Sep 2023 00:32:04 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDi-00BcTK-1H for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:39 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c4375c1406so10016615ad.1 for ; Fri, 15 Sep 2023 17:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824291; x=1695429091; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=C0sn2AnVcRbsYEvqFgh4BzWbc2uKAyyxP92cnWXv5Gc=; b=jqeMsobTypv41nhF1VsBMleCINHBpUELSqnt8vUayY4xXFsyJabfts/ZjIBqqig4xw CIgin4DlGvmDXNudjhlqfqMny+OyUbDLrINrcs4D2iUkndm8smYPtcxDawJ5+WExDrZV vZSYR0hK+1fGMz04imxewRFn9z4sV/QMgZMlEJ1BTX4Q/XYmYlxNyZ+MUAgGNlSILOIQ s8tbEK8rRbC6XVXi12CwnrwUbbFzAF6GsTPEAa7Yb3J2Gp6LrARIiAgaGqTlUZqsD0an LKW62bTiTq/6G95xX03fZXd2C5nLFSGSi80hSx/sgaElfOzsIJNpOmrzjWe+X4A5wAHU FO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824291; x=1695429091; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C0sn2AnVcRbsYEvqFgh4BzWbc2uKAyyxP92cnWXv5Gc=; b=EaFE26uh5/D/Ru1ijs9bMtoyrab1Y2YDpe2py5YVuBC+VlQvJwD6db9yM1P0aOiZLe z7A4NRJ/+EdLPLtxiS3CS0ntLlyl292Ud1UBJ4yWYpieY3bZ/11b7HKn2Yp6N5neazPE Gfb3mgRtMWGxd8Ca/Btq5ytXs48/zxEnXOMLLyYjeYjmcwUM4LZte1szGeWTWYKMvLZF uiTCq7quCkzgcB9XNU9IQSsKbdibDdcxar0+bNeykfyN/3WR+FibFrI1sI+/E5ckPiC8 HyY6F53U0pLf6HCMkAd5m1s2qJ8UTbngexEAd3SrLCR08LEBBLf1SHH2quePzq5ivyWA QGkQ== X-Gm-Message-State: AOJu0YzF1VzzFII1781ROgiNXCI3aHRMUozC2Z8AW9ek43G1rUVPi1tW oqAHIKfiodqt6XcvkP0t0NZSHEwOGB0= X-Google-Smtp-Source: AGHT+IHtRyj8S1iXRa1AyuzUMEtuqAzbJZbP2iFNCt3KVQZXM+xbuQMnV6uSJ406DSy/keoiXYz83X05kPo= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:41c2:b0:1c1:fbec:bc39 with SMTP id u2-20020a17090341c200b001c1fbecbc39mr73146ple.4.1694824290982; Fri, 15 Sep 2023 17:31:30 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:57 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-6-seanjc@google.com> Subject: [PATCH 05/26] vfio: KVM: Pass get/put helpers from KVM to VFIO, don't do circular lookup From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173134_492676_E2653AA8 X-CRM114-Status: GOOD ( 19.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Explicitly pass KVM's get/put helpers to VFIO when attaching a VM to VFIO instead of having VFIO do a symbol lookup back into KVM. Having both KVM and VFIO do symbol lookups increases the overall complexity and places an unnecessary dependency on KVM (from VFIO) without adding any value. Signed-off-by: Sean Christopherson Reviewed-by: Alex Williamson --- drivers/vfio/vfio.h | 2 ++ drivers/vfio/vfio_main.c | 74 +++++++++++++++++++--------------------- include/linux/vfio.h | 4 ++- virt/kvm/vfio.c | 9 +++-- 4 files changed, 47 insertions(+), 42 deletions(-) diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index a1f741365075..eec51c7ee822 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -19,6 +19,8 @@ struct vfio_container; struct vfio_kvm_reference { struct kvm *kvm; + bool (*get_kvm)(struct kvm *kvm); + void (*put_kvm)(struct kvm *kvm); spinlock_t lock; }; diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index e77e8c6aae2f..1f58ab6dbcd2 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -1306,38 +1305,22 @@ EXPORT_SYMBOL_GPL(vfio_file_enforced_coherent); void vfio_device_get_kvm_safe(struct vfio_device *device, struct vfio_kvm_reference *ref) { - void (*pfn)(struct kvm *kvm); - bool (*fn)(struct kvm *kvm); - bool ret; - lockdep_assert_held(&device->dev_set->lock); + /* + * Note! The "kvm" and "put_kvm" pointers *must* be transferred to the + * device so that the device can put its reference to KVM. KVM can + * invoke vfio_device_set_kvm() to detach from VFIO, i.e. nullify all + * pointers in @ref, even if a device holds a reference to KVM! That + * also means that detaching KVM from VFIO only prevents "new" devices + * from using KVM, it doesn't invalidate KVM references in existing + * devices. + */ spin_lock(&ref->lock); - - if (!ref->kvm) - goto out; - - pfn = symbol_get(kvm_put_kvm); - if (WARN_ON(!pfn)) - goto out; - - fn = symbol_get(kvm_get_kvm_safe); - if (WARN_ON(!fn)) { - symbol_put(kvm_put_kvm); - goto out; + if (ref->kvm && ref->get_kvm(ref->kvm)) { + device->kvm = ref->kvm; + device->put_kvm = ref->put_kvm; } - - ret = fn(ref->kvm); - symbol_put(kvm_get_kvm_safe); - if (!ret) { - symbol_put(kvm_put_kvm); - goto out; - } - - device->put_kvm = pfn; - device->kvm = ref->kvm; - -out: spin_unlock(&ref->lock); } @@ -1353,28 +1336,37 @@ void vfio_device_put_kvm(struct vfio_device *device) device->put_kvm(device->kvm); device->put_kvm = NULL; - symbol_put(kvm_put_kvm); - clear: device->kvm = NULL; } static void vfio_device_set_kvm(struct vfio_kvm_reference *ref, - struct kvm *kvm) + struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)) { + if (WARN_ON_ONCE(kvm && (!get_kvm || !put_kvm))) + return; + spin_lock(&ref->lock); ref->kvm = kvm; + ref->get_kvm = get_kvm; + ref->put_kvm = put_kvm; spin_unlock(&ref->lock); } -static void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm) +static void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)) { #if IS_ENABLED(CONFIG_VFIO_GROUP) - vfio_device_set_kvm(&group->kvm_ref, kvm); + vfio_device_set_kvm(&group->kvm_ref, kvm, get_kvm, put_kvm); #endif } -static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) +static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)) { struct vfio_device_file *df = file->private_data; @@ -1383,27 +1375,31 @@ static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm) * be propagated to vfio_device::kvm when the file is bound to * iommufd successfully in the vfio device cdev path. */ - vfio_device_set_kvm(&df->kvm_ref, kvm); + vfio_device_set_kvm(&df->kvm_ref, kvm, get_kvm, put_kvm); } /** * vfio_file_set_kvm - Link a kvm with VFIO drivers * @file: VFIO group file or VFIO device file * @kvm: KVM to link + * @get_kvm: Callback to get a reference to @kvm + * @put_kvm: Callback to put a reference to @kvm * * When a VFIO device is first opened the KVM will be available in * device->kvm if one was associated with the file. */ -void vfio_file_set_kvm(struct file *file, struct kvm *kvm) +void vfio_file_set_kvm(struct file *file, struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)) { struct vfio_group *group; group = vfio_group_from_file(file); if (group) - vfio_group_set_kvm(group, kvm); + vfio_group_set_kvm(group, kvm, get_kvm, put_kvm); if (vfio_device_from_file(file)) - vfio_device_file_set_kvm(file, kvm); + vfio_device_file_set_kvm(file, kvm, get_kvm, put_kvm); } EXPORT_SYMBOL_GPL(vfio_file_set_kvm); #endif diff --git a/include/linux/vfio.h b/include/linux/vfio.h index e80955de266c..35e970e3d3fb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -312,7 +312,9 @@ static inline bool vfio_file_has_dev(struct file *file, struct vfio_device *devi bool vfio_file_is_valid(struct file *file); bool vfio_file_enforced_coherent(struct file *file); #if IS_ENABLED(CONFIG_KVM) -void vfio_file_set_kvm(struct file *file, struct kvm *kvm); +void vfio_file_set_kvm(struct file *file, struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)); #endif #define VFIO_PIN_PAGES_MAX_ENTRIES (PAGE_SIZE/sizeof(unsigned long)) diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c index ca24ce120906..f14fcbb34bc6 100644 --- a/virt/kvm/vfio.c +++ b/virt/kvm/vfio.c @@ -37,13 +37,18 @@ struct kvm_vfio { static void kvm_vfio_file_set_kvm(struct file *file, struct kvm *kvm) { - void (*fn)(struct file *file, struct kvm *kvm); + void (*fn)(struct file *file, struct kvm *kvm, + bool (*get_kvm)(struct kvm *kvm), + void (*put_kvm)(struct kvm *kvm)); fn = symbol_get(vfio_file_set_kvm); if (!fn) return; - fn(file, kvm); + if (kvm) + fn(file, kvm, kvm_get_kvm_safe, kvm_put_kvm); + else + fn(file, kvm, NULL, NULL); symbol_put(vfio_file_set_kvm); } From patchwork Sat Sep 16 00:30:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1C79CD37B0 for ; Sat, 16 Sep 2023 00:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Yacda+PD9RmZ1F4kL3cA/9XEK1Y45nqVYPDAQ/ZnRxY=; b=It/nWzyro3aBSK 2+fencxPVvhgO4GofqZMKnt8fmKX0T3PEbNSWwX9sVsycKMWi4GKsiVbWBTSBL8GZ6SoYWzyx9MKV oh435l2Th4N48kWE9Mq0U8Rq1GIdwENtSDDIscm7VOuEystg0UpPPe1CPapy/wiepb65MTnxRigFE WFTVkWGKJRwFXv6K6pYyIA8Mr87ADKUZQvBV7kOq6zl8qrr0Mk9NjIEWZ8rqjGcuizAIopVX5avHr H7u2hBFPhtzxFX513tYm6vj9S9zItsFaN6VrQDZpA4UyPtFTXO0bXHDS3whJSfu4FPuy9H1ZSPVNd Dm5oP+I/FcjcklVfPdDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE3-00Bctv-2y; Sat, 16 Sep 2023 00:31:55 +0000 Received: from mail-yw1-f201.google.com ([209.85.128.201]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDj-00BcUd-0R for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:39 +0000 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59bf37b7734so29793387b3.0 for ; Fri, 15 Sep 2023 17:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824292; x=1695429092; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=qo2m7xsYGxv0LvZBx1IOU3suTnYOrGiO/bIX70mqbME=; b=wFTXSZSC7fjTmkdsO9oIhdXc38XaWY9xQ6fNyY36eiYYitav7tn5SLYzYS0oIRnPkp DleLLvScejLWd5bDdEoXjpf6vaAkEIUzgLIrj2wczFsfvEWx/dCyI99vKzqxzDu2ZY+L 2ss+GkdmX/1D32PaSq0U2udZQDANeWbN+3H3h4Lpjs9N4JqygWIyp2jeWxJELN/F5dyR XmA56DKUlPiQO+23VLS3K800F+z6bk1BNDvVlr78VV1sOtC3r0nQ+SVLWDYKomumYW3N ea4aE9wSsFGmCnS0Tb6W5TlAprO5yk/ewvg8zsDX0OU3Q2iIqTHuztBJ6jfme1t3nVas HOIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824292; x=1695429092; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qo2m7xsYGxv0LvZBx1IOU3suTnYOrGiO/bIX70mqbME=; b=CcyzUw1BXGoO6Ely87BfNxjzPvAnuYhEasfdz1sSxhgDdtQXFXygTpNHm89c/ob7Di GtmTSw244CBFiJTkvA5/994R0Q+bBs5YZ7NYDNRyJ8CkAfSicggvKJuNUtHjewm9pCvy +Ureq1fKPKPOBA7TskVpt9pP3jZ2HewKvXEZKq0AlcBe+G7ANm8BH0MSggK33Il+TdBP Nq7gPAQFs8VoSlAIiharyyAlBF05jYhAGLgGNAWF7I4iIWlsz6nBOfOG1qcD+m+1CQcm qtz0wFabXOXZ7yemGtrhzNirQ66A0/LAvXzpJJ67C5kPx3DOaK1mAPFP3ltggwdKNtQp ovhg== X-Gm-Message-State: AOJu0Yx6r0fDhufzweuOTBwdn4Lr7SX/cyuHOzhV9PmopfrOminNV37m 775r+80LEikDTOF8zGDLzT+LJLDycmM= X-Google-Smtp-Source: AGHT+IGldyHqJlNQwUdnpkugxOOkbUw+dVHZu9n7C9ywbITmCocjjVdCkDZmP9v50Lpi+O1mI86Ze95fAkM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:d045:0:b0:d7e:afff:c8fa with SMTP id h66-20020a25d045000000b00d7eafffc8famr73977ybg.5.1694824292733; Fri, 15 Sep 2023 17:31:32 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:58 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-7-seanjc@google.com> Subject: [PATCH 06/26] KVM: Drop CONFIG_KVM_VFIO and just look at KVM+VFIO From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173135_203455_14B2BE8B X-CRM114-Status: GOOD ( 13.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Drop KVM's KVM_VFIO Kconfig, and instead compile in VFIO support if and only if VFIO itself is enabled. Similar to the recent change to have VFIO stop looking at HAVE_KVM, compiling in support for talking to VFIO just because the architecture supports VFIO is nonsensical. This fixes a bug where RISC-V doesn't select KVM_VFIO, i.e. would silently fail to do connect KVM and VFIO, even though RISC-V supports VFIO. The bug is benign as the only driver in all of Linux that actually uses the KVM reference provided by VFIO is KVM-GT, which is x86/Intel specific. Signed-off-by: Sean Christopherson Reviewed-by: Jason Gunthorpe Reviewed-by: Alex Williamson --- arch/arm64/kvm/Kconfig | 1 - arch/powerpc/kvm/Kconfig | 1 - arch/s390/kvm/Kconfig | 1 - arch/x86/kvm/Kconfig | 1 - virt/kvm/Kconfig | 3 --- virt/kvm/Makefile.kvm | 4 +++- virt/kvm/vfio.h | 2 +- 7 files changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 83c1e09be42e..2b5c332f157d 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -28,7 +28,6 @@ menuconfig KVM select KVM_MMIO select KVM_GENERIC_DIRTYLOG_READ_PROTECT select KVM_XFER_TO_GUEST_WORK - select KVM_VFIO select HAVE_KVM_EVENTFD select HAVE_KVM_IRQFD select HAVE_KVM_DIRTY_RING_ACQ_REL diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig index 902611954200..c4beb49c0eb2 100644 --- a/arch/powerpc/kvm/Kconfig +++ b/arch/powerpc/kvm/Kconfig @@ -22,7 +22,6 @@ config KVM select PREEMPT_NOTIFIERS select HAVE_KVM_EVENTFD select HAVE_KVM_VCPU_ASYNC_IOCTL - select KVM_VFIO select IRQ_BYPASS_MANAGER select HAVE_KVM_IRQ_BYPASS select INTERVAL_TREE diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index 45fdf2a9b2e3..459d536116a6 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -31,7 +31,6 @@ config KVM select HAVE_KVM_IRQ_ROUTING select HAVE_KVM_INVALID_WAKEUPS select HAVE_KVM_NO_POLL - select KVM_VFIO select INTERVAL_TREE select MMU_NOTIFIER help diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index ed90f148140d..0f01e5600b5f 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -45,7 +45,6 @@ config KVM select HAVE_KVM_NO_POLL select KVM_XFER_TO_GUEST_WORK select KVM_GENERIC_DIRTYLOG_READ_PROTECT - select KVM_VFIO select INTERVAL_TREE select HAVE_KVM_PM_NOTIFIER if PM select KVM_GENERIC_HARDWARE_ENABLING diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index 484d0873061c..f0be3b55cea6 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -59,9 +59,6 @@ config HAVE_KVM_MSI config HAVE_KVM_CPU_RELAX_INTERCEPT bool -config KVM_VFIO - bool - config HAVE_KVM_INVALID_WAKEUPS bool diff --git a/virt/kvm/Makefile.kvm b/virt/kvm/Makefile.kvm index 2c27d5d0c367..29373b59d89a 100644 --- a/virt/kvm/Makefile.kvm +++ b/virt/kvm/Makefile.kvm @@ -6,7 +6,9 @@ KVM ?= ../../../virt/kvm kvm-y := $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/binary_stats.o -kvm-$(CONFIG_KVM_VFIO) += $(KVM)/vfio.o +ifdef CONFIG_VFIO +kvm-y += $(KVM)/vfio.o +endif kvm-$(CONFIG_KVM_MMIO) += $(KVM)/coalesced_mmio.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-$(CONFIG_HAVE_KVM_IRQ_ROUTING) += $(KVM)/irqchip.o diff --git a/virt/kvm/vfio.h b/virt/kvm/vfio.h index e130a4a03530..af475a323965 100644 --- a/virt/kvm/vfio.h +++ b/virt/kvm/vfio.h @@ -2,7 +2,7 @@ #ifndef __KVM_VFIO_H #define __KVM_VFIO_H -#ifdef CONFIG_KVM_VFIO +#if IS_ENABLED(CONFIG_KVM) && IS_ENABLED(CONFIG_VFIO) int kvm_vfio_ops_init(void); void kvm_vfio_ops_exit(void); #else From patchwork Sat Sep 16 00:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DDDCCD37AF for ; Sat, 16 Sep 2023 00:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=plcjLLiYT0sCezBYDpLPOFTa7FFkk3nF1kvc3scWZQ4=; b=dfDsjYdBPk6XLV o8nkEg4LOjqZntkwrKiifREhPe5gxR5frLu7k+PUVKm8q27U6i//ZPUMhOB5UexsdBIbtKHlxhkQs ziWX/A281rMwlXBi0sZvOIMMGk15lIzC9CqIPGR0Fdq/sEBkN8/rMBcZ9NbfOow5PUBYP3hblTS4E vPwqx4qm485iWIQrPZe47ZpmncaGZkcsvPzFS1Xbtxilu08yD7EuyNeULKE9kP1fF317KYZ7neMVS hW+iNIUhMd5zCSNHjkF1dnUA4oVXTr5NkYmiWZua9OTY+rgOUr4N5vUXkjcf0ThtASTXEkZXxgz9p 2C4yYYc/U23+PQOtWsnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJER-00BdJZ-03; Sat, 16 Sep 2023 00:32:19 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDj-00BcWO-2S for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:42 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81a47e12b5so2554433276.0 for ; Fri, 15 Sep 2023 17:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824294; x=1695429094; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=XQRlLqUbNuYp1+FU2drQZXL0G0BiKv3N4ijMXeK3kKU=; b=zQXFtQs55sQWzJP2r74/AoNgMQw52YinyTrPKu4Wra6+n4dYwmLau4z69Gmqe0e6b0 DmbNo/kxuZJTAo+UsdH2c0O6L/gEaC5m4Zcds7K83BS9XNLJwiskGsIBab9u90mVcldS higlRY0p8jgLH1jL9G2QwmjEkK+OS2C6nTf9YWle6AAN0ne6pCm9TNYmjtGJzX/WNljA Mil/hkKDCB8IZmz1ry1ZEXWzPcf3gBt5bb8HGAhD105ZX2gm+lB43ddYEKtIWzByTqJ2 +fkofOLLXw07slzGKnrczeX4AZKkHIATTMONf8cL7mpGo1dN9Kp5+sxSkqrM6mJkr3ti z2Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824294; x=1695429094; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XQRlLqUbNuYp1+FU2drQZXL0G0BiKv3N4ijMXeK3kKU=; b=Z+Zxfcsvarquk6HCEIJxFEXbaoKFyTCNqgt2e8kFviFcpO+tYxPioG0ZGxr6R2j0Ms 399K+/AN3gIHANtNxw65ORkW6MbdQczpp3BRxp/xDb16DBBLao1Oj28jawb4jlLiwC/5 x8F4LERnZjWIgpIkMaADuYMVAafpoK+fJvKF/xPp+HlTTEnb+QE5BcEeQylaURoCsPUp kbuvz/MVGqpYzHLOP0x160tFcWb3i4RaMeSdVdvS+ROif5Mlvk7hJODTSUf07oM3uEZP 8syjmvNr7fPwhAu+rKQHvK97G3nzSelJ6H7Zd5ecEoy1f6jsAHK/M3kp6k2uxL/eWShO HJIA== X-Gm-Message-State: AOJu0YzNkxxxt7JB6LKIbggQyVRwNqmMaKRQyFMDVvnu6zQs2bRYZR/Z iQYStRzVUOF9Dp8l6W9K/+4Eq4ZmQ0s= X-Google-Smtp-Source: AGHT+IHBAJpKVTk5K4TnqnuCpKfAMfti0UcZajyltDkU/ESq4jqN2J77nrZn8mACY7DFJ5DSU6KVipQ1KO4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:aa6c:0:b0:d7e:a025:2672 with SMTP id s99-20020a25aa6c000000b00d7ea0252672mr72126ybi.9.1694824294437; Fri, 15 Sep 2023 17:31:34 -0700 (PDT) Date: Fri, 15 Sep 2023 17:30:59 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-8-seanjc@google.com> Subject: [PATCH 07/26] x86/idt: Wrap KVM logic with CONFIG_KVM instead of CONFIG_HAVE_KVM From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173135_832205_92AF04A7 X-CRM114-Status: GOOD ( 15.71 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Wrap all of the IDT-related code that deals with KVM in CONFIG_KVM instead of CONFIG_HAVE_KVM. x86 always "has" KVM, i.e. checking CONFIG_HAVE_KVM is pointless. Alternatively, the #ifdefs could simply be deleted, but the only potential value is in printing the number of posted interrupts that end up being handled by the host, everything else is completely dead code when KVM is disabled. And if KVM is disabled, there should not be any posted interrupts, i.e. NOT wiring up the "dummy" handlers and treating IRQs on those vectors as spurious is the right thing to do. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/hardirq.h | 2 +- arch/x86/include/asm/idtentry.h | 2 +- arch/x86/include/asm/irq.h | 2 +- arch/x86/include/asm/irq_vectors.h | 2 +- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/irq.c | 4 ++-- scripts/gdb/linux/constants.py.in | 2 +- scripts/gdb/linux/interrupts.py | 2 +- tools/arch/x86/include/asm/irq_vectors.h | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h index 66837b8c67f1..fbc7722b87d1 100644 --- a/arch/x86/include/asm/hardirq.h +++ b/arch/x86/include/asm/hardirq.h @@ -15,7 +15,7 @@ typedef struct { unsigned int irq_spurious_count; unsigned int icr_read_retry_count; #endif -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) unsigned int kvm_posted_intr_ipis; unsigned int kvm_posted_intr_wakeup_ipis; unsigned int kvm_posted_intr_nested_ipis; diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index 05fd175cec7d..8eef16d0d72b 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -671,7 +671,7 @@ DECLARE_IDTENTRY_SYSVEC(IRQ_WORK_VECTOR, sysvec_irq_work); # endif #endif -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_VECTOR, sysvec_kvm_posted_intr_ipi); DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_WAKEUP_VECTOR, sysvec_kvm_posted_intr_wakeup_ipi); DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_NESTED_VECTOR, sysvec_kvm_posted_intr_nested_ipi); diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h index 836c170d3087..194dfff84cb1 100644 --- a/arch/x86/include/asm/irq.h +++ b/arch/x86/include/asm/irq.h @@ -29,7 +29,7 @@ struct irq_desc; extern void fixup_irqs(void); -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void)); #endif diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index 3a19904c2db6..3f73ac3ed3a0 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -84,7 +84,7 @@ #define HYPERVISOR_CALLBACK_VECTOR 0xf3 /* Vector for KVM to deliver posted interrupt IPI */ -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) #define POSTED_INTR_VECTOR 0xf2 #define POSTED_INTR_WAKEUP_VECTOR 0xf1 #define POSTED_INTR_NESTED_VECTOR 0xf0 diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index b786d48f5a0f..a9e6363d88c2 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -149,7 +149,7 @@ static const __initconst struct idt_data apic_idts[] = { #ifdef CONFIG_X86_LOCAL_APIC INTG(LOCAL_TIMER_VECTOR, asm_sysvec_apic_timer_interrupt), INTG(X86_PLATFORM_IPI_VECTOR, asm_sysvec_x86_platform_ipi), -# ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) INTG(POSTED_INTR_VECTOR, asm_sysvec_kvm_posted_intr_ipi), INTG(POSTED_INTR_WAKEUP_VECTOR, asm_sysvec_kvm_posted_intr_wakeup_ipi), INTG(POSTED_INTR_NESTED_VECTOR, asm_sysvec_kvm_posted_intr_nested_ipi), diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 11761c124545..35fde0107901 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -164,7 +164,7 @@ int arch_show_interrupts(struct seq_file *p, int prec) #if defined(CONFIG_X86_IO_APIC) seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); #endif -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) seq_printf(p, "%*s: ", prec, "PIN"); for_each_online_cpu(j) seq_printf(p, "%10u ", irq_stats(j)->kvm_posted_intr_ipis); @@ -290,7 +290,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_x86_platform_ipi) } #endif -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) static void dummy_handler(void) {} static void (*kvm_posted_intr_wakeup_handler)(void) = dummy_handler; diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index e3517d4ab8ec..054630f511e0 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -129,7 +129,7 @@ LX_CONFIG(CONFIG_X86_MCE_THRESHOLD) LX_CONFIG(CONFIG_X86_MCE_AMD) LX_CONFIG(CONFIG_X86_MCE) LX_CONFIG(CONFIG_X86_IO_APIC) -LX_CONFIG(CONFIG_HAVE_KVM) +LX_CONFIG(CONFIG_KVM) LX_CONFIG(CONFIG_NUMA) LX_CONFIG(CONFIG_ARM64) LX_CONFIG(CONFIG_ARM64_4K_PAGES) diff --git a/scripts/gdb/linux/interrupts.py b/scripts/gdb/linux/interrupts.py index ef478e273791..66ae5c7690cf 100644 --- a/scripts/gdb/linux/interrupts.py +++ b/scripts/gdb/linux/interrupts.py @@ -151,7 +151,7 @@ def x86_show_interupts(prec): if cnt is not None: text += "%*s: %10u\n" % (prec, "MIS", cnt['counter']) - if constants.LX_CONFIG_HAVE_KVM: + if constants.LX_CONFIG_KVM: text += x86_show_irqstat(prec, "PIN", 'kvm_posted_intr_ipis', 'Posted-interrupt notification event') text += x86_show_irqstat(prec, "NPI", 'kvm_posted_intr_nested_ipis', 'Nested posted-interrupt event') text += x86_show_irqstat(prec, "PIW", 'kvm_posted_intr_wakeup_ipis', 'Posted-interrupt wakeup event') diff --git a/tools/arch/x86/include/asm/irq_vectors.h b/tools/arch/x86/include/asm/irq_vectors.h index 3a19904c2db6..3f73ac3ed3a0 100644 --- a/tools/arch/x86/include/asm/irq_vectors.h +++ b/tools/arch/x86/include/asm/irq_vectors.h @@ -84,7 +84,7 @@ #define HYPERVISOR_CALLBACK_VECTOR 0xf3 /* Vector for KVM to deliver posted interrupt IPI */ -#ifdef CONFIG_HAVE_KVM +#if IS_ENABLED(CONFIG_KVM) #define POSTED_INTR_VECTOR 0xf2 #define POSTED_INTR_WAKEUP_VECTOR 0xf1 #define POSTED_INTR_NESTED_VECTOR 0xf0 From patchwork Sat Sep 16 00:31:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C1B6CD37AF for ; Sat, 16 Sep 2023 00:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G6SwJpK8DPnGe/urjycPceIX3xwWrmATFipdEs2n6sM=; b=GY8S1AFuBUUjoy pPYfBeIbSRKenCgOtyLuASZDAI+jKFMDp6CNIlFrXitiFmO1rkXwiweCyhq6HbhCmll4PqmocbmoC FrB9udDi2bpewFlM/y+aytAnAyd1hNNS2IDrWVlejXZ4qBnId9007vo3nID2oVyQBqpF6Mbdxrsqa 7v+ITEVguXDnHdoTDw4kSKk28cNMLRJCLpbU0Eam5LsQUP4Wxo/Z1UKEDYGVCgnfCTO+qBpQYHNbE rzhVy1En7zv7/Rug0dvALVsYBA7G/7WdTUCZptuOct74xvu0pWOy90H1pGP1WHPvTNVXFYENtKJoy I5y6CghJPeakRTKRq+uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEY-00BdPp-2g; Sat, 16 Sep 2023 00:32:26 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDl-00BcYu-2S for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:44 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d8186d705a9so3253438276.3 for ; Fri, 15 Sep 2023 17:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824296; x=1695429096; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=2bGNmVCdNvvogzEXgW0zNdAXreJziaadtBBldNfFmhI=; b=iQBlC65+WYSUwsFZaugF+xqK6pfS58neBPSfOjpnauT/98TeYN5k34n26f69zxE++Z Ko9gZpB1R44XHo9h7NK/UDszUvlCRvSD6SY/1H8CN1I0wLT/hyFvNILOZL2tp+HkTUHs GLNo6Y18AGaY8VgIcW8Ma6U/XItUO4JYqujgeP8n0nf8SNoD4wKQCoG1CtQl0R0wQTg1 HiKvwCQUSW37/j4X1gboYqo4IhDka+hjjwhsai7/+l2Hyzpn+lTbg6YU3LxpigZ5qRra CjW+udOM42Ems7DrRAsVsFwiAcTHPPERV+d3KUEUjSippyZ9S5NFdzsW19eRZRo/IAvd 1eFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824296; x=1695429096; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2bGNmVCdNvvogzEXgW0zNdAXreJziaadtBBldNfFmhI=; b=gyCeLsQWJiyuApgioIqhIDe9AZZkS/Ea3ZOuOuVNLv/+Q4olpJ9fa+j+1X2+S49SyV /ggEp6BqJ+AIsT8wNYyk22klot/j0N2kPU4YMlfqOi+NJdLFXvr/jPBcqaHLpoK22pZg ZJQhA7F+B5c7iPBcQbq1EJiArLL68/BtSaIbTaM4ulgqEhhLAaJ5N1OGM+ySZgWADPNg GGufGgA6090tWGmNio5QfbHsMxrvb039uNenkhJpQ/a8bph4Q8AtjKEulIIkLSx8C1LP 1nTnqmyv9FAMBDErBGhitkaL6FPxmtsRKQ7AY0XCU8YFETugy58DifYV1Dn9HEck2uMP Y/oA== X-Gm-Message-State: AOJu0YwuwHw2BzOIgnaucUN4R/s0oWkcEIIbk13Nb8TLXTwM2QqGssJ/ I1CNJhN46BIOhnWosuTMhS9VvFm+i5c= X-Google-Smtp-Source: AGHT+IEii4782d+JzWBACVp4gsfxYcFW3PZ67SLHnb796XbOz2rrTeQdE9Xb83Qlv7LO8McNRbBpWAwnK1E= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2982:0:b0:d05:98ef:c16b with SMTP id p124-20020a252982000000b00d0598efc16bmr77753ybp.5.1694824296181; Fri, 15 Sep 2023 17:31:36 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:00 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-9-seanjc@google.com> Subject: [PATCH 08/26] KVM: x86: Stop selecting and depending on HAVE_KVM From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173137_828268_4A9478AB X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that nothing in x86 or architecture agnostic code consumes HAVE_KVM, stop selecting it in x86. This is one of several steps towards deleting HAVE_KVM from the common KVM Kconfig. Signed-off-by: Sean Christopherson --- arch/x86/Kconfig | 1 - arch/x86/kvm/Kconfig | 2 -- 2 files changed, 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 982b777eadc7..32eb288a4e3a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -240,7 +240,6 @@ config X86 select HAVE_FUNCTION_ERROR_INJECTION select HAVE_KRETPROBES select HAVE_RETHOOK - select HAVE_KVM select HAVE_LIVEPATCH if X86_64 select HAVE_MIXED_BREAKPOINTS_REGS select HAVE_MOD_ARCH_SPECIFIC diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 0f01e5600b5f..8c5fb7f57b4c 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -7,7 +7,6 @@ source "virt/kvm/Kconfig" menuconfig VIRTUALIZATION bool "Virtualization" - depends on HAVE_KVM || X86 default y help Say Y here to get to see options for using your Linux host to run other @@ -20,7 +19,6 @@ if VIRTUALIZATION config KVM tristate "Kernel-based Virtual Machine (KVM) support" - depends on HAVE_KVM depends on HIGH_RES_TIMERS depends on X86_LOCAL_APIC select PREEMPT_NOTIFIERS From patchwork Sat Sep 16 00:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBDF2CD37AF for ; Sat, 16 Sep 2023 00:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TpYyUbXZgsR706lNjzLgdTlZ5UT7FfBJLMs45vtqg3Y=; b=x4XgZDx44evDYl M+F6fcH3Gyn5zpwMIIWiXr7t2zik5wGBU4wO5BQs1kG+enKcVYqsThTMhAl3ocgsH8bqxegcvGz8z tdaicQNeCfokqfDVMYodB0m2aCzbqkWSA8YGrtfcP6f05Wn/vTamgX+9aEaASScHFjj2l/ac75wtE ploFgve9nqWMoOWFR7B7EU13sdh8E8PKub35Tfj1FrPyfmD5VgHwT6nawLp74sDKa6u5jiSCjaTeu /uj9tEX1scV4LA5iQZyW5FK3LfNsVTnz4uV/zrj3TXJVH3VixBD/+4m4ebz2m15Cn2i0jrI7hwK11 r2DVLY0n5MAdguGRkNeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEr-00BdgN-0H; Sat, 16 Sep 2023 00:32:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE0-00Bcpo-2G for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OjnVLG9a9LJLqorH8Rj1ZnrY26noTE5ZeEoscx0wCrE=; b=GMkBlfFU3/QtZBpYj2COtGCDKG BC2RH2mSxAM5vZNUOpKxyw2QNXpz0lK5xaVWoUD6xKdwJUD9bDhiFaDiaLoxpbh/Z2TCciCWuX9ao nz4lpoTwlTWFqr/wx7Xi8ifCA57bLirk9gh/ZDLDE5Q0XMxUuwFhpyywyqZNfyebMLtI1cPVv8O1R NJqe/vcdztWKUcPxIwyXB+Z8R3tqMAs1Jp2kt2heSGurHbZUPXxjyhJjSq1nMON6ONu8IDm13m1Tt hSIY6cF3KpM2AadOdZ+6cyyC7NvRNdxhcxken/YetJPQaoVWOMTCHBWc8b25utVGwgNDLpUbI4k1z RB+835+Q==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDn-009jlU-13 for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:50 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-cf4cb742715so3251782276.2 for ; Fri, 15 Sep 2023 17:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824298; x=1695429098; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=OjnVLG9a9LJLqorH8Rj1ZnrY26noTE5ZeEoscx0wCrE=; b=gP91xEZAkGKYTxIDJIwNDjVpUvoxlxAinQAJW3KiWuYdgk4axoq82fVd3+dQ268xox L0addWzKPQy9g8sS0bCE1zn+5rBgaCsuRml8HLzIhBc0p1CdjR5BYs9NpbT5f9/q6M7N 1sZ7aXLbpnGvGoJyB2amwgEIyHm/pJx1/lND+wAhsdx7EekTqibhBUn+s78X0C1zwayW GxgTltcoMhgpwc8r3ffCzsUDTcdswdaM4dIQa7xqLoba+RSfYrFzMdKONPPllYaB0V8y xSHxu0EEhr7oavB+wm68Q3r9sDrauus1m0J7w7LWDstl+Vd0KMCC9zpOPkg/yVvpyP6K HTjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824298; x=1695429098; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OjnVLG9a9LJLqorH8Rj1ZnrY26noTE5ZeEoscx0wCrE=; b=IhSh3b+g3xmXMAs6oAer3WuS3biCS3GwuElLMNKCUU+9Q62NTrNqOh+KchP/y8+/lf 1/Db4UtHs0SFrhYnDB85Mykf6QZbi+8mY/XjZktGjT5wjmGJdlnzMWMzsazted+VzdVp uqAQaGh7JmT4z0cYjhV3PbKxoaS28N9sb9YF/kkMRaz9T1mA+mtWBUpCxjSKg+pnvYlh KLcLFkvGDvw8XmqXqQWcNeAd2Bs98jtmd+p54LsnkrIQZRyOrL71xwSMpNX15l2RpIsc miqzuiRzTghA1ygTvn6H4eSCZveZecVUYrIvCFDqRfgmaHu7JO34GDGNWEfaTKKAX4VU sfhg== X-Gm-Message-State: AOJu0YyqTEDSMotpkQM3gtFDlCRKea2s6qfjdQcpj+f/Yl8eCdbY3mpB 8ohqjCNu/T4N2ZQAyy4UZqqURu7EVYc= X-Google-Smtp-Source: AGHT+IEejUplN0yThqJglSyf2PAl899GMvDcyB4OaKD9HL7AL2P8QSuIFDWAjhltJc72cwzADimsWD5lopA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:138e:b0:d78:245a:aac4 with SMTP id x14-20020a056902138e00b00d78245aaac4mr82623ybu.1.1694824298283; Fri, 15 Sep 2023 17:31:38 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:01 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-10-seanjc@google.com> Subject: [PATCH 09/26] KVM: arm64: Stop selecting and depending on HAVE_KVM From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013140_987163_5C4E109A X-CRM114-Status: GOOD ( 10.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that nothing in arm64 or architecture agnostic code consumes HAVE_KVM, stop selecting it in arm64. This is one of several steps towards deleting HAVE_KVM from the common KVM Kconfig. Signed-off-by: Sean Christopherson --- arch/arm64/Kconfig | 1 - arch/arm64/kvm/Kconfig | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b10515c0200b..7d99f132e57c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -214,7 +214,6 @@ config ARM64 select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IOREMAP_PROT select HAVE_IRQ_TIME_ACCOUNTING - select HAVE_KVM select HAVE_MOD_ARCH_SPECIFIC select HAVE_NMI select HAVE_PERF_EVENTS diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 2b5c332f157d..c76af1973315 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -20,7 +20,6 @@ if VIRTUALIZATION menuconfig KVM bool "Kernel-based Virtual Machine (KVM) support" - depends on HAVE_KVM select KVM_GENERIC_HARDWARE_ENABLING select MMU_NOTIFIER select PREEMPT_NOTIFIERS From patchwork Sat Sep 16 00:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4AC1DCD37B5 for ; Sat, 16 Sep 2023 00:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5AaYswakxa+tcc64Rdiz1hzTqnwJPIagFHN9GlYt9SY=; b=IDEF5sAlg5FapD MSVAkY6wLNaxw4PSu5zD8ThxiL3T1sDcDUfAto20hBGxHZeOjBHwIhEL4k9F6P3rfBxSysASgbsoy miD5lh6kNNUWBYzLG92QRC5t+U6ojL9yam99RUP4C5afUDUcS+fE5JzAbwR7+fvMu/gtkTSaF+qk8 sYnhjokScVdTxvIDhzrUZUlqtfk+zCAmEfaSUz4EjBJ7ZQyHGTIRhMK1QErPw0YTjnc0m2SYYHu96 ct8bnyg5haUvLXai6Wt2VbGG/8hudSJomQ8CXc+kigq02J2cnwxmb5jwWRbGoaUuTNQvWq1cJINhx zU2Zx93u6YwuYSJOuNRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEm-00Bdbo-2F; Sat, 16 Sep 2023 00:32:40 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDy-00Bco2-2s for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RPxwiI+CF5oY5axnD8PplP8rMTdwT2bOTUtJzDVfTIk=; b=PUigVEVaZz+lsq/Q3BtyIDCTme Av2oE0uXilLriuuxulWehHg5gMA+A1qFbzRbLwIrWQKicpTrwXu7TkSU77eFxzutHNY6MbL+9xSlC 6iw+quUPqP+JZlPBNF/YV06NJ9mfwfF0dMo0PGKEONpXEtI1CWcFYxmYDUncCiu6RB+R9jv2/FlVE 927lXQhnJbUL8MxcE26R2TAj0s29sUwky810Nw7ySLw2Z3YZpPI+VLEQKp9YDvCmA+l8bcpFcUguv i7cDoFOmUtrkSBFAJywMr/C4pZ6BDxT5arore9yyX8xJWhy+LGbRqPkqyebc/S+5OT+Euyc/MgMxr zr3bzang==; Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDr-009jmV-1i for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:49 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c43cd8b6cbso8823365ad.0 for ; Fri, 15 Sep 2023 17:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824300; x=1695429100; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=RPxwiI+CF5oY5axnD8PplP8rMTdwT2bOTUtJzDVfTIk=; b=Zd/zfv038dYUiRDxyELg0a6fDlsmbrpWr5tB+aXZA/vfZf87102BawQPdKPDc9FhQU vYXK6IOnOmCrJDuWw3V2yHmqGsMf+jkmYGkuQL+5MlPa55hXwDjVIOLV1z9s/zltRqIo 70iU43IrHOtsnz0KJG1YkRzPhFpxAisLFE+4wS9U4CB0Qhx85Qtp5Lazq/81INBrV/kv +zdszbRt5SRPQCiGc0x2MC8TKulgKOA2gRSxEixb0ggd9mQLDNi9m1gN1gFkAZdSz4zc 3SNNpxWM7MI+I3I/x3T95JH6A76Ys6PM85ibFJwokhUcolSCEjvIDztgjPkhFdRMofS1 EdmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824300; x=1695429100; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RPxwiI+CF5oY5axnD8PplP8rMTdwT2bOTUtJzDVfTIk=; b=hN9xDVVsnJC7imTn/M8Wgc7H826INYnHCXdaeLaV1ZFToYCTJ5x//3UrQs85p3saso V6cNj3Ylt/7762GEN8cMjUos16deIMWX08pnKsnIyaiZgadQs6vInKgLW4LDj1g2G4hY Zmqh+m5Rvdiu+QAS0SFOkLEqJTJYeoPrfP09F0Z+GKlZ/BjVIxybaKd/dtc4IE9AV4l6 JTI4Jajp/I0bxA+f+UrReXvpYH52hTsKLCiYwCEbVUfdqDEGD53ZQ6UzRptEFjcszuYo mD/AmN6HKsi0nsawshT8yTj3ph++OnTmZUj713pc2iZ/HwAp8GYIH2CiNfp2OdProTVv jkfg== X-Gm-Message-State: AOJu0YxHiY7fPjaSpka6I9TpmcrzHWw34AYXowdk9mkvIml4dSCzRRTh AwHpt7BqJqPSE5IS73zcIwVwkVOkkJ8= X-Google-Smtp-Source: AGHT+IHW1P62bdhU5bhLcOltXlUxrv9g7sIQXkfjHJs3Wzbb395eeX6g+RNXiUsvwMV2ESouovB/6KamMFU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2302:b0:1b8:a555:385d with SMTP id d2-20020a170903230200b001b8a555385dmr88540plh.9.1694824300497; Fri, 15 Sep 2023 17:31:40 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:02 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-11-seanjc@google.com> Subject: [PATCH 10/26] KVM: s390: Stop selecting and depending on HAVE_KVM From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013147_761531_D1F8B7FB X-CRM114-Status: GOOD ( 10.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that nothing in s390 or architecture agnostic code consumes HAVE_KVM, stop selecting it in s390. This is one of several steps towards deleting HAVE_KVM from the common KVM Kconfig. Signed-off-by: Sean Christopherson Reviewed-by: Claudio Imbrenda --- arch/s390/Kconfig | 1 - arch/s390/kvm/Kconfig | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index ae29e4392664..8a5dca0036d9 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -193,7 +193,6 @@ config S390 select HAVE_KPROBES select HAVE_KPROBES_ON_FTRACE select HAVE_KRETPROBES - select HAVE_KVM select HAVE_LIVEPATCH select HAVE_MEMBLOCK_PHYS_MAP select HAVE_MOD_ARCH_SPECIFIC diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index 459d536116a6..9056cee72945 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -19,7 +19,6 @@ if VIRTUALIZATION config KVM def_tristate y prompt "Kernel-based Virtual Machine (KVM) support" - depends on HAVE_KVM select PREEMPT_NOTIFIERS select HAVE_KVM_CPU_RELAX_INTERCEPT select HAVE_KVM_VCPU_ASYNC_IOCTL From patchwork Sat Sep 16 00:31:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F020CD37B0 for ; Sat, 16 Sep 2023 00:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J8Zh/cWkpFaIJrkh1DpbOBj+rwQKUOQAVKno5xe9Pv8=; b=EC/4GHAyWw1JsU BWRoB2WDmxrvHDST5fle9I/1KJPxxFAin3pou413clAz3vlzzb71aGbaQDiFPrdnJ3GHGXHNDwDs9 5nC9EBLv6kGMtqymlsCnxtwOJp7G0sy0BU5Ej81jalNCDTAufdMuppTZIRofwyq0hLJbIxu9MRJFJ LxCxvZZLMAyBTbsJO3mzYF8Un6Y+GT16YT0/8FdG4YPy+Etw+GP9UUZY9ck6GJLlJDfsuEWsMNTd0 B0DO7+OHMgGy2RZpJQuZ4zRgCrkgk+Yyew53dRTGgdrDChD6qjUOAw+jORVguo6GrC3HrwohmmqSi a8cekQZum5Pml0JPIzAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEl-00BdaC-0m; Sat, 16 Sep 2023 00:32:39 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDy-00BcoL-38 for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=11iXbA6RA96N2ihdzvT9DOzykVF8TPNgieg32BOfaCo=; b=EYxRb5wEnwwZASPVPrnRQN3uPi 6mzBmPXkRjeK2gPjgxYSrnUKAsEuxzQMDEmCtzj3ujnIp2kbvWLLQV9or8wyzmk4vyIHfHKDbW9+z meL5l8nQEQfwTMYn+6JxjFksSl8MUOdI3ux9xXiBq904pP0eQNUzc9kLI74C+ROGvLB+7StKQSVAD RM9WnfEskP0d/ANMTSrH/uiG9vQrii64UHlmyCu4noGlfEbMZQWjUBEHSpBw3xKnhbtn4UgK9h79c fcwdfPanj7W4TeO5bQbaHamkyvGqkLuFF6eHXeAz334GdU0lIgu225zHYK76+8IHe0M/5T+VJOwvz sAOOsRAw==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDt-009jmm-10 for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:49 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d8191a1d5acso2868008276.1 for ; Fri, 15 Sep 2023 17:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824302; x=1695429102; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=11iXbA6RA96N2ihdzvT9DOzykVF8TPNgieg32BOfaCo=; b=a2CBc8IA8PV2pD8hTo+WqCu9+mN0WTn2ZhyOSiMr0xeTBAlIyXvGMmX+qLL0dGKrf8 QXecz9U+fHXwvhN8L7xn9ickv/3heVuYn+EUfINzq8WJqESHK2Jafvnpeg6ygZWZtDvW ksR6mDUZTLPxmnwvRAyfZu+sjnfsr2vBSfqdu1QYUq9l4yWtLQj9agxM8iM+VZ+SJizg pyLoKE34QPqbFWooR6SMc56WnO+lLqJYjJXopahiKAwioaNp6Bnl2vnDgi8EDDjEiQb3 Fwc3YEvH16Vr6F8AS1CmL+/mTaCmxKLyxTTouUeLZZ0Kt5Q9/n8M3MS2gs45AhRyYBqd LqxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824302; x=1695429102; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=11iXbA6RA96N2ihdzvT9DOzykVF8TPNgieg32BOfaCo=; b=NPuoeodeDG9Z7RgptDhg9C4BEL62/0ZpHw7NqBIb4LLil+VuSRZdZWJiSc8YNLSdCK 7mdEO4MS62O1te21CR+p6N7K0ZMFtnbzomCYKsbxnKpoYCrR/CvejHsiGCYBNaJm1qos YI/m0Z7iyWULjW39nUBqDzXNVj/Cl5MLJpjsI38mcUHvT6PuSXodnVvuG2xEmch1bshE shzQPDSh2W2Alzkl43GijEeMYtoWC72SKq3N3kORO7ptJWBo/EDw75BlAjTcCV4DFwh5 nUdZcb8y5ZGWve6dZZaDTSFnWObu3JzGr7GJYvMdGYXSa4x2NgtuCLCCWfAJEa6hK7dI 8F5g== X-Gm-Message-State: AOJu0YyBfuJ+WVaCqAaQJ03hDI80YyrGXH3udmm/jjtxiRyMb0wwC4hK aYgz0W3EX4PZHrI3Qwv0gIRS+DFBcM4= X-Google-Smtp-Source: AGHT+IEXzBZMjfoz19MMDpz0z/mfp5J4Xc54+oTqT/y9sTC3/YRTAU+NLkJhdnChwcXUDWkKwhep1BL4HMg= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:138e:b0:d78:245a:aac4 with SMTP id x14-20020a056902138e00b00d78245aaac4mr82625ybu.1.1694824302614; Fri, 15 Sep 2023 17:31:42 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:03 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-12-seanjc@google.com> Subject: [PATCH 11/26] KVM: MIPS: Make HAVE_KVM a MIPS-only Kconfig From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013148_072398_13A94E3F X-CRM114-Status: GOOD ( 10.93 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that MIPS is the sole remaining user of HAVE_KVM, make HAVE_KVM a MIPS-only Kconfig. Because most architectures unconditionally support virtualization, advertising to the kernel at-large that an arch has KVM just led to a bunch of useless and misguided #ifdefs. Signed-off-by: Sean Christopherson --- arch/mips/kvm/Kconfig | 3 +++ virt/kvm/Kconfig | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig index a8cdba75f98d..c4508f49caae 100644 --- a/arch/mips/kvm/Kconfig +++ b/arch/mips/kvm/Kconfig @@ -4,6 +4,9 @@ # source "virt/kvm/Kconfig" +config HAVE_KVM + bool + menuconfig VIRTUALIZATION bool "Virtualization" help diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index f0be3b55cea6..f7bb6c59658e 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # KVM common configuration items and defaults -config HAVE_KVM - bool - config HAVE_KVM_PFNCACHE bool From patchwork Sat Sep 16 00:31:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CCC2CD37B1 for ; Sat, 16 Sep 2023 00:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xHPyoVuX1hP6lBG3H5zsAneUt79JQ3sFY9L76KSCwiQ=; b=Qw2E+IOBQaT+6O ih6emaq0Yc3ZUKiyzR3VVhrKCdKH7c3md3MX4fUberG4ogT3wVvIHVmo4BTdBJHfsX6dva1NTlBU/ R+RtS2+tGk0czXaGEIucG9tOQaAFEeDZMwuqKBm33PsQHZLAjf3ooBvvn05Vh9tiU/rpMx8TipbkD IWA2EJPCp97zv5ugUZ7RxArcfvrimQZPJdHDF4jVr4Kgdgq97T+H8Axr5Ef2jWMc2DBHHIdI+MhGt EOWIgnRx60mKpHxJCK9lVqlV76s8K6CO5J3097J/sU9fh2otNyuAhPfGqzi+pN+DlDX94Qa2d/PYe 5FTflye0i5Z5PB2cqeBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJF6-00BduK-11; Sat, 16 Sep 2023 00:33:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE1-00BcqK-05 for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=T4d9JtkzBqCpjbUcqi6GepdBrHqatH15LR+RcbQRSno=; b=k3poX6uUFwwz9vVTOUN+Gr8zDB p/2LR1Knx2Z1C48nR+o65pYpPlNI1VvrXe1hwc3Ktwgcaw5cPFsMJJpncptxEuUCRkpd2tul1FiZe BtkVJCmjNBi9X2RqFCK2ulH/ay3RrEVMGD8qj2eXtliXrKdfJEPmdCatrPxbHyoebeZ4SjJn4KHPm BwK0zwcf4plp9hBUBMLIu9MF+ADd2mtqccA1SZc+kgmC4Two+vG31TLvoRxii9I3KOn3NMV+kYwB6 doVxI3aNUexTCCtOxz+Ao/zy2UnM7NIhE1qfXUj7WrlCKy8+dymDip6RBhr8vkzl+EJeLw5kwjJbe yC3eDDXw==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDu-009jmq-3A for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:51 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59c07ca1b44so21116897b3.3 for ; Fri, 15 Sep 2023 17:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824304; x=1695429104; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=T4d9JtkzBqCpjbUcqi6GepdBrHqatH15LR+RcbQRSno=; b=jIk0sYFArxUpghYY6TCMeshdQuCoCJ3R1VmYYXok/L19Kjtn17gRmHVV+fd4kN/Sk4 K5pNqzfwHugktGP8wK14eP4bhBZvlxPTXFeXPvA+vP0NVUXSfAv/T8aWrL/Tm7lakaPn uKnLMWlFRgO0DM2cRw8/XP3claOZw8s/wFS32e0zeQifETRXrKG0go23Clx6TYHvZImu R1LnnJMAV9ndyaKQAM2GQJM2S9+UfoSZV+zYJAHlWm1EFskQtwx98z1dgMJSHqKIguFv t5S0OGkQSq3UNFuKxAh52H7mTkbs+oqCznOPe/iUyqAgSgm54IJNnfW2p42HlcDf/RB6 HVgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824304; x=1695429104; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T4d9JtkzBqCpjbUcqi6GepdBrHqatH15LR+RcbQRSno=; b=r91NQxeD3Kfc2qf6r++ywXu4HX5VxVn5y+i/vUEcq6iGRPUsau919x2hmhkQeDOcSb PBjM2PHguoZq0KKb0m+Un9Yt1UgthI1ZL4zjgHoOTGZdq4tJIqnXBKIVZB63nJsT0Rgx P0p7Cmi6SAr9OQzfRqX+hczsT3aWA1Nto8W0/xFeWJBV6iCeH1x9OqPwJvis1JfL7L3W GSinDPJ0r3abSKzk33lhW7/8yYcI4S6OAuuIdCJmQix88eLuoJSUt1UWTjPbgmJAnRD1 vdXS1KJsH4eymcOty6CLwOrEif7Vsy1gV77YAoG0haHdD0gR2oYMOUspzmQYMUfJb+bX FrJA== X-Gm-Message-State: AOJu0YxF4aWbCPQvEEqup2IS9PHdvTWY345jfqLCYvdp/gGdy5v/gMXG PJMtKHsBHchVenfl5iLPs9SjymEjkTQ= X-Google-Smtp-Source: AGHT+IFHuI3+InjaYoGpeoRnBjmpOWBEwR2qvNTEjtEAfl3mVa5tl1N1hW80goIMLDXxJcvVvIl5YUYpSE0= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:181b:b0:d81:4107:7a1 with SMTP id cf27-20020a056902181b00b00d81410707a1mr70396ybb.2.1694824304643; Fri, 15 Sep 2023 17:31:44 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:04 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-13-seanjc@google.com> Subject: [PATCH 12/26] KVM: arm64: Move arm_{psci,hypercalls}.h to an internal KVM path From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013148_703799_88D83B2E X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Anish Ghulati Move arm_hypercalls.h and arm_psci.h into arch/arm64/kvm now that KVM no longer supports 32-bit ARM, i.e. now that there's no reason to make the hypercall and PSCI APIs "public". Signed-off-by: Anish Ghulati [sean: squash into one patch, write changelog] Signed-off-by: Sean Christopherson --- arch/arm64/kvm/arm.c | 5 +++-- {include => arch/arm64}/kvm/arm_hypercalls.h | 0 {include => arch/arm64}/kvm/arm_psci.h | 0 arch/arm64/kvm/guest.c | 2 +- arch/arm64/kvm/handle_exit.c | 2 +- arch/arm64/kvm/hyp/Makefile | 4 ++-- arch/arm64/kvm/hyp/include/hyp/switch.h | 4 ++-- arch/arm64/kvm/hyp/nvhe/switch.c | 4 ++-- arch/arm64/kvm/hyp/vhe/switch.c | 4 ++-- arch/arm64/kvm/hypercalls.c | 4 ++-- arch/arm64/kvm/psci.c | 4 ++-- arch/arm64/kvm/pvtime.c | 2 +- arch/arm64/kvm/trng.c | 2 +- 13 files changed, 19 insertions(+), 18 deletions(-) rename {include => arch/arm64}/kvm/arm_hypercalls.h (100%) rename {include => arch/arm64}/kvm/arm_psci.h (100%) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 4866b3f7b4ea..6de1d63b981b 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -41,9 +41,10 @@ #include #include -#include #include -#include + +#include "arm_hypercalls.h" +#include "arm_psci.h" static enum kvm_mode kvm_mode = KVM_MODE_DEFAULT; diff --git a/include/kvm/arm_hypercalls.h b/arch/arm64/kvm/arm_hypercalls.h similarity index 100% rename from include/kvm/arm_hypercalls.h rename to arch/arm64/kvm/arm_hypercalls.h diff --git a/include/kvm/arm_psci.h b/arch/arm64/kvm/arm_psci.h similarity index 100% rename from include/kvm/arm_psci.h rename to arch/arm64/kvm/arm_psci.h diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 95f6945c4432..32045ad51ec4 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include +#include "arm_hypercalls.h" #include "trace.h" const struct _kvm_stats_desc kvm_vm_stats_desc[] = { diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 617ae6dea5d5..f1d02d6f8683 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -21,7 +21,7 @@ #include #include -#include +#include "arm_hypercalls.h" #define CREATE_TRACE_POINTS #include "trace_handle_exit.h" diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile index a38dea6186c9..4ce8c86967b5 100644 --- a/arch/arm64/kvm/hyp/Makefile +++ b/arch/arm64/kvm/hyp/Makefile @@ -4,7 +4,7 @@ # incdir := $(srctree)/$(src)/include -subdir-asflags-y := -I$(incdir) -subdir-ccflags-y := -I$(incdir) +subdir-asflags-y := -I$(incdir) -I$(srctree)/arch/arm64/kvm +subdir-ccflags-y := -I$(incdir) -I$(srctree)/arch/arm64/kvm obj-$(CONFIG_KVM) += vhe/ nvhe/ pgtable.o diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 9cfe6bd1dbe4..cd21cf71d7db 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -16,8 +16,6 @@ #include #include -#include - #include #include #include @@ -31,6 +29,8 @@ #include #include +#include "arm_psci.h" + struct kvm_exception_table_entry { int insn, fixup; }; diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index c353a06ee7e6..c0553ac36a46 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include @@ -29,6 +27,8 @@ #include #include +#include "arm_psci.h" + /* Non-VHE specific context */ DEFINE_PER_CPU(struct kvm_host_data, kvm_host_data); DEFINE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt); diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index 6537f58b1a8c..f7423c890b5c 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include @@ -28,6 +26,8 @@ #include #include +#include "arm_psci.h" + /* VHE specific context */ DEFINE_PER_CPU(struct kvm_host_data, kvm_host_data); DEFINE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt); diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index 7fb4df0456de..d34a31c9ace2 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/hypercalls.c @@ -6,8 +6,8 @@ #include -#include -#include +#include "arm_hypercalls.h" +#include "arm_psci.h" #define KVM_ARM_SMCCC_STD_FEATURES \ GENMASK(KVM_REG_ARM_STD_BMAP_BIT_COUNT - 1, 0) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index 1f69b667332b..c461e15026c9 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -13,8 +13,8 @@ #include #include -#include -#include +#include "arm_hypercalls.h" +#include "arm_psci.h" /* * This is an implementation of the Power State Coordination Interface diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c index 4ceabaa4c30b..b07d250d223c 100644 --- a/arch/arm64/kvm/pvtime.c +++ b/arch/arm64/kvm/pvtime.c @@ -8,7 +8,7 @@ #include #include -#include +#include "arm_hypercalls.h" void kvm_update_stolen_time(struct kvm_vcpu *vcpu) { diff --git a/arch/arm64/kvm/trng.c b/arch/arm64/kvm/trng.c index 99bdd7103c9c..b5dc0f09797a 100644 --- a/arch/arm64/kvm/trng.c +++ b/arch/arm64/kvm/trng.c @@ -6,7 +6,7 @@ #include -#include +#include "arm_hypercalls.h" #define ARM_SMCCC_TRNG_VERSION_1_0 0x10000UL From patchwork Sat Sep 16 00:31:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64044CD37B0 for ; Sat, 16 Sep 2023 00:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hzq3WIje2lhuDBxY94IJOR3faCvsVWTcKj3qHjJ198g=; b=0sb3+Uul9Pl/oA OZIuDAxWotozGQiyIQcZCwkNzTep6RoG1xWAQEpBB56tSaGRMCCua3WHXIkKkSKITgxw5r7NJS/1m +3GTgDGWtT+jGlXVRG7Ex5Cf+6DP+b0Fqivebtxx9tpkfBhvg2Q0sBoETA7Y6RIK/nN/gs7s5sXFg 9i63Yc6/JwMAWDdx+Qep2uc/843eyzX0G7u1Ogi8xbPrrZvufjKAxfDIFVWSZqAyMc4i2gnwtXSbk h+0gJyRusAWjUohnnW19Rojc1UsJRKIbAr8bAFodsdo6Txct369ABWS7eNQ14W0GriQc09CGnjQlO 4qDw1zuUz5D9jtHymO0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJFE-00Bdze-1g; Sat, 16 Sep 2023 00:33:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE1-00BcqG-0T for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HQNUEYOJ/ozgdrFnqx+YRCy2I1exOHPHuH58RF8SFNA=; b=Cv2dVCelloI2jvc3ArIrNobhdB 7++KjjHTNO5mU0nMJkr4m4HTVd40z9JA0HwjUmxpnKafLYEONB9LUeYD5d7Ws6L/GovvNzbhAX9f4 3Iqf40RIJi2sITK86tIT00ifY8d4bBVRxltSj2pnRGILsMQX5w3GyN4b2UXzqSGZ7yy7racG6WUId g4JMwrUQJusfYGoRJcZnrESxXjVqrkEgt/eAGJuTwlrmRGOX/9Ek41xCNm27xynJz1amIcvwSTkzG 3EGDnR1QDPBCUy6jJQfhXN7HtQporohLtEyfPs4sGn23GG2pDnV9b0F76wxpRHf7p1Q9WvjStViP0 t+kcvSAA==; Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDv-009jn0-1H for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:51 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c395534687so25925505ad.1 for ; Fri, 15 Sep 2023 17:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824306; x=1695429106; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=HQNUEYOJ/ozgdrFnqx+YRCy2I1exOHPHuH58RF8SFNA=; b=xtcTa6R+fjOqPDMK+dMCzbfGnP+mt9FBizhVDXI7GAUuEE3UIJpB90UrBqy7s/cyvk O+lmFh5WFdE2noCr1FPdbSGPPeG+WQl1MiddhCIF59HW9vPm4zIgFqv0athXOQcDPv4r tyFubLUgsD5oMX3M6ooPg/h/Lqr1JrL7dJmi1XwCvFIRWNxDut/Qm8MDpp7YDGL3x+vV +SRGwLTkxxEmADaAaPn1fq9UP5QUJXxtjlKkayxbur6MoVAakp8t8bETjLZiY0JWTWiT 5jnVpewRimnDqFFME+55pckflxO91k9QxYtIy3MajxDt/hWKkbH3UOnihuAV0j460Nxp 8vXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824306; x=1695429106; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HQNUEYOJ/ozgdrFnqx+YRCy2I1exOHPHuH58RF8SFNA=; b=OK9hgWMPCzU+yKBWgnPIget2HFKqDgad6Pe+k0GK9DlTSC/q4OT3eQpuusQ3q9bBXU +oDJsNowVSnyDBLo5brQxqKlYQidendS2cB81FusGu/mkuxHFec60256a0NLVm+Ndprg CDvbO3ZC5CSFxCpaWG8CrEY1YRCiikiEnE9QyGZiA9gv9yuCd5dX3VTixi+Ua12oHZLu SMLkbDQEk81fES2csKCKRltuG/IRmFpFuBQEIZSSaWCaV/KDwideQzVCnB1kJ0aW2HOo Dtj3i6pqeddW3OifaT3tfnKVzNeh1uIdjW2xnd2bFHQcmXlWdqDuy/7ANtk/VIS9f5Sh J7VQ== X-Gm-Message-State: AOJu0Ywrp2uPz1TBYbZ33JRQXEvT/q3+Msg+hoMlfjH6mzUlX1irmxWh 1gOi3FaRgMcjFO0tUZJwawPXBwvp3Bs= X-Google-Smtp-Source: AGHT+IHwZjKrwGdEWszMvnFwhRAkOaZ4ZXt/sllxoteViYwmhz1Ar6ouDJgF8x4FFhszG2C3n1vTw2Lw6BE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:32ca:b0:1b8:8c7:31e6 with SMTP id i10-20020a17090332ca00b001b808c731e6mr93755plr.1.1694824306427; Fri, 15 Sep 2023 17:31:46 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:05 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-14-seanjc@google.com> Subject: [PATCH 13/26] KVM: arm64: Include KVM headers to get forward declarations From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013149_201130_62287493 X-CRM114-Status: UNSURE ( 9.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Include include/uapi/linux/kvm.h and include/linux/kvm_types.h in ARM's public arm_arch_timer.h and arm_pmu.h headers to get forward declarations of things like "struct kvm_vcpu" and "struct kvm_device_attr", which are referenced but never declared (neither file includes *any* KVM headers). The missing includes don't currently cause problems because of the order of includes in parent files, but that order is largely arbitrary and is subject to change, e.g. a future commit will move the ARM specific headers to arch/arm64/include/asm and reorder parent includes to maintain alphabetic ordering. Reported-by: kernel test robot Signed-off-by: Sean Christopherson --- include/kvm/arm_arch_timer.h | 2 ++ include/kvm/arm_pmu.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h index bb3cb005873e..e22a15c66288 100644 --- a/include/kvm/arm_arch_timer.h +++ b/include/kvm/arm_arch_timer.h @@ -7,6 +7,8 @@ #ifndef __ASM_ARM_KVM_ARCH_TIMER_H #define __ASM_ARM_KVM_ARCH_TIMER_H +#include +#include #include #include diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index 31029f4f7be8..e80f1d090579 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -7,6 +7,8 @@ #ifndef __ASM_ARM_KVM_PMU_H #define __ASM_ARM_KVM_PMU_H +#include +#include #include #include From patchwork Sat Sep 16 00:31:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EE47CD37AF for ; Sat, 16 Sep 2023 00:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dXGvbeZKdr6etSAnjXyLOJSGB5lUDrDReBdGbzP/2ZY=; b=BP5HoCjzyjSrI9 6s0ZjdHh1jy9n4vvF3takG1n2uWr8V0bJ6l2hx+Jj7ShSypRc2HACKLxMsQwWQwZCpiMVKImuFqPv 6QOK8fsWLBpBly90QFLdGuZjih3Xm86U4tBpRxpJkkytCUZ/VrpIUy+e+umGiccfK0qpMSzCx4d0v MobldnyRtRSRe0pwOG3jBv841ZPSdmXBp4iS/cfe83XMbCCyVfaQ5mw5Y2bFDP8K1bM8nMh+wVAr5 tSPRPA7CfDY8t75O1dXIiHQLht9LFQVAXH4P5nAzVtpazCOwBT216apa7amPdNgd7bJZwfU2idCxZ pmYhtOsEvBjRXVj2Rmtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJFW-00BeHD-20; Sat, 16 Sep 2023 00:33:26 +0000 Received: from mail-pl1-f202.google.com ([209.85.214.202]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDz-00BcnK-2z for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:57 +0000 Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1c4159a5e03so21507795ad.2 for ; Fri, 15 Sep 2023 17:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824309; x=1695429109; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=Sk1hp6a+9RZ3IPJ6o3Xc56HeuESZXshWdRu3KxHYbOk=; b=tz4hOupO0MFInIA5VMRnU+uy8bElx/cBR2lqix2GJ+S2Ca6CzvJR+/WS8lzGE9M4j5 /3WTf5/2bwD9nqtXmz5RBV2mQE4GCVkBHxdRAgKROyQGE6ITHDU3h21hs+dMMZGcN40Q 0sUEH322bsMxdGs3hNjoZoCmoYhZFydyfTmq6v2mo6dTWglFz2+IjPpCMBjFArK3e5O9 bVkIV34A07ehC/6i3gsTIXLpDSDpc40NkDazdwUEqY0dBjyEmr0zpoNazbcBML0ZR964 Co0gEApmdf/Pjr4jKoHWLnteno34kb6M0WzRf0/ldI/0HxX8/xHjczvBOkZaqVtnOx+/ zXww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824309; x=1695429109; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sk1hp6a+9RZ3IPJ6o3Xc56HeuESZXshWdRu3KxHYbOk=; b=G74+1MwemH/5thSHXG2SuXbZJQ8oZV1QFBeDBPZE2jW07JW7/TfUOO1TCHTNzNuqyU O4X85pmi0qKNQtBPpABZVwmjAPfv0f2hblT5nH6rMGcbyRv++rtsF5TiJBfehYjizvHm 9AuzgwXuoVYs/BfEDDTgOzh5Z7nOCpzl+eDf6S6vBe9ZFyejlwj0dkKD4mKG+mRnvdVx lxISuOEnXL12iLvx0SIweZ3jjSpcT+vFH8ZdChLIQH3Yt/Eq32dUxJQF2kO1fSPv7AWX VSBmSZw9QiTK96rHJv3RkQa55jsZY6/KvQEUtIxTAC7Nve/S00MmecDJJfk/YUrHTyli 4R6w== X-Gm-Message-State: AOJu0YyuXuLXDQyX+3YGQKxzgFwHSjkG/rqSDKG+cJio9+9Tc67x/xV8 EML6eK1c1ogJwZpzZpni/xU0ku3FX4c= X-Google-Smtp-Source: AGHT+IEU0Z6VTALFS9lpMvjwmAs1FMCn1bdYRkBSaQPqDHqpJxatiQ9z1iTR+rqsJ4lFbhN56fBBI/37KSI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:f341:b0:1b9:df8f:888c with SMTP id q1-20020a170902f34100b001b9df8f888cmr57331ple.8.1694824308805; Fri, 15 Sep 2023 17:31:48 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:06 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-15-seanjc@google.com> Subject: [PATCH 14/26] KVM: arm64: Move ARM specific headers in include/kvm to arch directory From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173152_005354_D90CF3CF X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move kvm/arm_{arch_timer,pmu,vgic}.h to arch/arm64/include/asm and drop the "arm" prefix from all file names. Now that KVM no longer supports 32-bit ARM, there is no reason to expose ARM specific headers to other architectures beyond arm64. Signed-off-by: Sean Christopherson --- .../arm64/include/asm/kvm_arch_timer.h | 0 arch/arm64/include/asm/kvm_host.h | 7 +++---- include/kvm/arm_pmu.h => arch/arm64/include/asm/kvm_pmu.h | 0 .../kvm/arm_vgic.h => arch/arm64/include/asm/kvm_vgic.h | 0 arch/arm64/kvm/arch_timer.c | 5 ++--- arch/arm64/kvm/arm.c | 3 +-- arch/arm64/kvm/pmu-emul.c | 6 +++--- arch/arm64/kvm/reset.c | 3 +-- arch/arm64/kvm/trace_arm.h | 2 +- arch/arm64/kvm/vgic/vgic-debug.c | 2 +- arch/arm64/kvm/vgic/vgic-init.c | 2 +- arch/arm64/kvm/vgic/vgic-irqfd.c | 2 +- arch/arm64/kvm/vgic/vgic-kvm-device.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio-v2.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio.c | 4 ++-- arch/arm64/kvm/vgic/vgic-v2.c | 2 +- arch/arm64/kvm/vgic/vgic-v3.c | 2 +- 18 files changed, 21 insertions(+), 25 deletions(-) rename include/kvm/arm_arch_timer.h => arch/arm64/include/asm/kvm_arch_timer.h (100%) rename include/kvm/arm_pmu.h => arch/arm64/include/asm/kvm_pmu.h (100%) rename include/kvm/arm_vgic.h => arch/arm64/include/asm/kvm_vgic.h (100%) diff --git a/include/kvm/arm_arch_timer.h b/arch/arm64/include/asm/kvm_arch_timer.h similarity index 100% rename from include/kvm/arm_arch_timer.h rename to arch/arm64/include/asm/kvm_arch_timer.h diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index af06ccb7ee34..90cfbf420545 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -26,16 +26,15 @@ #include #include #include +#include #include +#include +#include #define __KVM_HAVE_ARCH_INTC_INITIALIZED #define KVM_HALT_POLL_NS_DEFAULT 500000 -#include -#include -#include - #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS #define KVM_VCPU_MAX_FEATURES 7 diff --git a/include/kvm/arm_pmu.h b/arch/arm64/include/asm/kvm_pmu.h similarity index 100% rename from include/kvm/arm_pmu.h rename to arch/arm64/include/asm/kvm_pmu.h diff --git a/include/kvm/arm_vgic.h b/arch/arm64/include/asm/kvm_vgic.h similarity index 100% rename from include/kvm/arm_vgic.h rename to arch/arm64/include/asm/kvm_vgic.h diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 6dcdae4d38cb..5e40bea8f3f3 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -14,12 +14,11 @@ #include #include +#include #include #include #include - -#include -#include +#include #include "trace.h" diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 6de1d63b981b..6480628197b4 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -39,10 +39,9 @@ #include #include #include +#include #include -#include - #include "arm_hypercalls.h" #include "arm_psci.h" diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c index 6b066e04dc5d..b5d999adce56 100644 --- a/arch/arm64/kvm/pmu-emul.c +++ b/arch/arm64/kvm/pmu-emul.c @@ -11,10 +11,10 @@ #include #include #include -#include -#include -#include #include +#include +#include +#include #define PERF_ATTR_CFG1_COUNTER_64BIT BIT(0) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 7a65a35ee4ac..ad5e239774f1 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -17,12 +17,11 @@ #include #include -#include - #include #include #include #include +#include #include #include #include diff --git a/arch/arm64/kvm/trace_arm.h b/arch/arm64/kvm/trace_arm.h index 8ad53104934d..76ef72de6133 100644 --- a/arch/arm64/kvm/trace_arm.h +++ b/arch/arm64/kvm/trace_arm.h @@ -3,7 +3,7 @@ #define _TRACE_ARM_ARM64_KVM_H #include -#include +#include #include #undef TRACE_SYSTEM diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c index 07aa0437125a..2d542040008c 100644 --- a/arch/arm64/kvm/vgic/vgic-debug.c +++ b/arch/arm64/kvm/vgic/vgic-debug.c @@ -9,7 +9,7 @@ #include #include #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 c8c3cb812783..9f548ffac90b 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include "vgic.h" diff --git a/arch/arm64/kvm/vgic/vgic-irqfd.c b/arch/arm64/kvm/vgic/vgic-irqfd.c index 475059bacedf..c35e1a138617 100644 --- a/arch/arm64/kvm/vgic/vgic-irqfd.c +++ b/arch/arm64/kvm/vgic/vgic-irqfd.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "vgic.h" /** diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c index 212b73a715c1..2c7027d675c9 100644 --- a/arch/arm64/kvm/vgic/vgic-kvm-device.c +++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c @@ -6,7 +6,7 @@ * Author: Marc Zyngier */ #include -#include +#include #include #include #include diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v2.c b/arch/arm64/kvm/vgic/vgic-mmio-v2.c index e070cda86e12..bba0cfeefffe 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v2.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v2.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include "vgic.h" #include "vgic-mmio.h" diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 188d2187eede..d54a90beef61 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -9,11 +9,11 @@ #include #include #include -#include #include #include #include +#include #include "vgic.h" #include "vgic-mmio.h" diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c index ff558c05e990..68a3d8062473 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.c +++ b/arch/arm64/kvm/vgic/vgic-mmio.c @@ -10,8 +10,8 @@ #include #include #include -#include -#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 7e9cdb78f7ce..7eacf1c850a5 100644 --- a/arch/arm64/kvm/vgic/vgic-v2.c +++ b/arch/arm64/kvm/vgic/vgic-v2.c @@ -6,7 +6,7 @@ #include #include #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 3dfc8b84e03e..e8501828072b 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include From patchwork Sat Sep 16 00:31:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFD27CD37B1 for ; Sat, 16 Sep 2023 01:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FwUYq+jltvEJ5tcNZ9dUlmjsoxw8pqWF17vVltq5Pys=; b=j+JMhNLL42LTXV xehPuA2e6WlPk+sCRxB15IPCaUPw1ZWIdBqo9scWfynH9FFzl9Ro74Uuu3tAhr0752oKJ5abiC0fS HStbYh5U09UTtEpX0JQSYL9+9HO4Wz58o2lLKQDsN+l5dDR1c4HhyQWQqYF83FwMGBHAto4hdt9CO MlyK8vHXYhnL/LbGq6KkL+N0T2eTwWieuTIY3OL5im76aPY9Djm7Kb0PQnq1uIq2jIMMipv7U74vM rHjqKFkakyOEIz0R3sehF/Z4zPBZn0NSbgxUNH6JQk9Xq460lMyO/Mqi0c5cNPd4Ly+2gyTn3yt+y MfLWAn4xMhvztm2tOPFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhKNs-00BkKV-0b; Sat, 16 Sep 2023 01:46:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE5-00BcvV-1W for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:31:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K+4wLZRg/fEoTWN91R6Hud4ODei52D2o77Nnp/okXhc=; b=kT/B5DIxUW62fMp/omn8trlYXd 74a5U2rVB0zG6A2fOx9NPNvc2VvbG+rTk6spPoH0eLIUATromaHaNmIXYMOC5LVu+tD2w4uQHJYlP VQZE8a0axXMGwDvRLvz5EnIB7g/m/zVg0nxA4NE4yUamS969TtC+12n3toBU7COuerXG06G1v2OPO YpRa5cddqj/ZanPcqXZV14UqY0MfwZ5nwURR+u/DmkkJiSrJqwrz63KpLeytammRmDqcd8+u20l+c WSrYUroGgO1GeI8clBfdCMJsqrT885XZ2sX3IpA1dUxcaw+7tlnRRjgadYUWOjpmL7No/O8VaOPMk /9A0E2wg==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJDz-009jp2-1q for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:55 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59c0dd156e5so14959267b3.3 for ; Fri, 15 Sep 2023 17:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824311; x=1695429111; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=K+4wLZRg/fEoTWN91R6Hud4ODei52D2o77Nnp/okXhc=; b=ardzaCAtI2HgL/xbdoeih2eo3lfON+OibnNG+qwiVBlhquMJ7BlOcAMwzQyJxvlTlX cSqvrHQBUTCKdls9kmHskRcb1XwWA4TAATKwBShM0Zb2kT7jYkHfQJ+Btjup2F69W0qz h9JEirh767fsHo0AinHgiTJBNt4qlPXUTImkVUgEopDS3Wlq8A4J3ZDXt/WuUnsVCLDy 4NrmgkbEF0GQzf+480GEgDOGz0R0OLEurRENRhWI2wBnqsZBQ8yF0SlajwDPYpuq84Xr okfQjUrk8W91uZ1PNs0dxntzibka8V+QCxEqDkWB26gDuuzK/FBkHAC2SUjpYO+taSFl UXOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824311; x=1695429111; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K+4wLZRg/fEoTWN91R6Hud4ODei52D2o77Nnp/okXhc=; b=jnmgg+i0epIqwz1Omr5xbaaer7WiGQrKlG5QQ9QFt/TBxgTY15vOsgsum8yaqYt6AL oN6xaMXU8NLn8VaozwjqQciRpLH6lFYxyJvLcS6svLI66UQobN0CkMtcmGfAKOEVR5ZN sVWGsFiwtrEZD1oBwUFZA40ukfKghT2aKk4X0VTn1FPpsEE64OQ9CQRzvv4GFMZgs/9e oFvW7JvrzJuo6v9QF6pHaNGZFgFB9jxQc1/Q8XNBPXFcbB0n9fUPa6B8SctGHLExlgva w1LJYuJSAzWs1QZ6vmN67i3xecNFkfXtMltyxBEB34iD63irb7kjtAL2ABieyYj94CrW MK/Q== X-Gm-Message-State: AOJu0Yy+94VY8Ld0m9oLg8yDbiTXoTTZtMIs1yMVEyosKMIxUjrU2IrB RNjRAbdrCf1g0WfxvmUjjz+6klwlv6Y= X-Google-Smtp-Source: AGHT+IGeLhjeWaYzJPE1mCnK9Csjwjlwkmu8U9lPUcubvqyfYiZpHoa2TM+ffhRiOESL+mVFdN06uDg2kmM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:ca08:0:b0:59b:f493:813c with SMTP id p8-20020a81ca08000000b0059bf493813cmr84977ywi.9.1694824310900; Fri, 15 Sep 2023 17:31:50 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:07 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-16-seanjc@google.com> Subject: [PATCH 15/26] KVM: Move include/kvm/iodev.h to include/linux as kvm_iodev.h From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013153_392934_EB4E44A5 X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move iodev.h, the last remaining holdout in include/kvm, to the standard include/linux directory as kvm_iodev.h and delete include/kvm. Signed-off-by: Sean Christopherson Acked-by: Anup Patel --- MAINTAINERS | 1 - arch/arm64/include/asm/kvm_vgic.h | 2 +- arch/arm64/kvm/vgic/vgic-mmio-v2.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio.c | 2 +- arch/mips/include/asm/kvm_host.h | 3 +-- arch/powerpc/kvm/mpic.c | 2 +- arch/riscv/kvm/aia_aplic.c | 2 +- arch/riscv/kvm/aia_imsic.c | 2 +- arch/x86/kvm/i8254.h | 2 +- arch/x86/kvm/ioapic.h | 2 +- arch/x86/kvm/irq.h | 2 +- arch/x86/kvm/lapic.h | 2 +- include/{kvm/iodev.h => linux/kvm_iodev.h} | 0 virt/kvm/coalesced_mmio.c | 3 +-- virt/kvm/eventfd.c | 2 +- virt/kvm/kvm_main.c | 3 +-- 17 files changed, 15 insertions(+), 19 deletions(-) rename include/{kvm/iodev.h => linux/kvm_iodev.h} (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 90f13281d297..ddc8375d536c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11498,7 +11498,6 @@ W: http://www.linux-kvm.org T: git git://git.kernel.org/pub/scm/virt/kvm/kvm.git F: Documentation/virt/kvm/ F: include/asm-generic/kvm* -F: include/kvm/iodev.h F: include/linux/kvm* F: include/trace/events/kvm.h F: include/uapi/asm-generic/kvm* diff --git a/arch/arm64/include/asm/kvm_vgic.h b/arch/arm64/include/asm/kvm_vgic.h index 5b27f94d4fad..2ca52888bc75 100644 --- a/arch/arm64/include/asm/kvm_vgic.h +++ b/arch/arm64/include/asm/kvm_vgic.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v2.c b/arch/arm64/kvm/vgic/vgic-mmio-v2.c index bba0cfeefffe..646053ee892f 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v2.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v2.c @@ -6,9 +6,9 @@ #include #include #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 d54a90beef61..b79a2e860415 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c index 68a3d8062473..4feca3b1d915 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.c +++ b/arch/arm64/kvm/vgic/vgic-mmio.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index 54a85f1d4f2c..f8f63d0aa399 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -24,8 +25,6 @@ #include #include -#include - /* MIPS KVM register ids */ #define MIPS_CP0_32(_R, _S) \ (KVM_REG_MIPS_CP0 | KVM_REG_SIZE_U32 | (8 * (_R) + (_S))) diff --git a/arch/powerpc/kvm/mpic.c b/arch/powerpc/kvm/mpic.c index 23e9c2bd9f27..b25a03251544 100644 --- a/arch/powerpc/kvm/mpic.c +++ b/arch/powerpc/kvm/mpic.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #define MAX_CPU 32 #define MAX_SRC 256 diff --git a/arch/riscv/kvm/aia_aplic.c b/arch/riscv/kvm/aia_aplic.c index 39e72aa016a4..b49e747f2bad 100644 --- a/arch/riscv/kvm/aia_aplic.c +++ b/arch/riscv/kvm/aia_aplic.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include struct aplic_irq { diff --git a/arch/riscv/kvm/aia_imsic.c b/arch/riscv/kvm/aia_imsic.c index 6cf23b8adb71..586e466a1c6d 100644 --- a/arch/riscv/kvm/aia_imsic.c +++ b/arch/riscv/kvm/aia_imsic.c @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h index a768212ba821..4de7a0b88e4f 100644 --- a/arch/x86/kvm/i8254.h +++ b/arch/x86/kvm/i8254.h @@ -4,7 +4,7 @@ #include -#include +#include struct kvm_kpit_channel_state { u32 count; /* can be 65536 */ diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h index 539333ac4b38..2beec2daf1a3 100644 --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -3,7 +3,7 @@ #define __KVM_IO_APIC_H #include -#include +#include #include "irq.h" struct kvm; diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index c2d7cfe82d00..f9530e9a66f8 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include #include "lapic.h" #define PIC_NUM_PINS 16 diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 0a0ea4b5dd8c..bfd99ad1882e 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -2,7 +2,7 @@ #ifndef __KVM_X86_LAPIC_H #define __KVM_X86_LAPIC_H -#include +#include #include diff --git a/include/kvm/iodev.h b/include/linux/kvm_iodev.h similarity index 100% rename from include/kvm/iodev.h rename to include/linux/kvm_iodev.h diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c index 1b90acb6e3fe..cfcb4b84d632 100644 --- a/virt/kvm/coalesced_mmio.c +++ b/virt/kvm/coalesced_mmio.c @@ -9,8 +9,7 @@ * */ -#include - +#include #include #include #include diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 89912a17f5d5..4d7cfb1095fd 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -26,7 +26,7 @@ #include #include -#include +#include #ifdef CONFIG_HAVE_KVM_IRQFD diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 486800a7024b..f585a159b4f5 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -13,9 +13,8 @@ * Yaniv Kamay */ -#include - #include +#include #include #include #include From patchwork Sat Sep 16 00:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 686DDCD37AF for ; Sat, 16 Sep 2023 00:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VuqwCC/xzvv4MzxZfqhcwF2rbda88SK01A8h9BqqcKg=; b=ksL85VDc1nJnU6 BfOdE7TuJv6UxxszrVuxxaNeG0aiy6UBKSXgTpwCOoeZHTAaH/ZacppW862y8zeJ/nDnTeKt7uBHR fE7sIA9k6zGN1E1CWVrcGP8QEpORpT80akyzXoj7hk1Avr2U7AaUIW4Le24jx4E86tcHA7te71yp+ pYBzwtNhY4NSeQmSAjbtZDa9hGhaYqGAa0vQk/1TZ+U9sSDG5sYvcq8NYIb1mE+FjT8mALkxkC4x0 OwjxHiVOeJL0uvSQu6nxGt66/WGau/LlaH3Xqf7SsflE0D1OHxJ+Wd/mZqRk9o5yGFzDWRzE7+AMd yIGVYnw3JYpwoMyu+CHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJFi-00BeSr-0A; Sat, 16 Sep 2023 00:33:38 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE2-00Bcre-2t for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:01 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59bdac026f7so35874577b3.0 for ; Fri, 15 Sep 2023 17:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824313; x=1695429113; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=pl7bBxxWVXjTf9iTQwKV6iNN5dTCLVhIVjlh92R6IC4=; b=2wL0dC+Ie68imWXPl9ttHYBB2q4O14qk2NtSE+7UaYNVeAAKgZelp8y2qmoV1NpoY6 cMxpwKuLNl09usfz9bLOiMgfYPvUtOjE3CIbsNya5oUj/DFYLRxiYyZC5lQD3i6uMzox ySBuGzC6RecbsuB3DAO/jn8hnZdissZJ+PV4sZ0OgXnjsu5u/q3EfqGYwy06WMe3I11a IQycKDAv+9t3zEejpAgDJ8t6/JePI/CcMV9Wq42vb1atEOKA/LZ7zMGl/aGtKun4LSad n+ND2YzNAB/R9eRyAcK5b+Ib3q0OueQ86XF1W3iw+LORYUKe/LPfkzTQudXcWgkF59Gm EMQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824313; x=1695429113; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pl7bBxxWVXjTf9iTQwKV6iNN5dTCLVhIVjlh92R6IC4=; b=ANStIR2vmz10o2f61WK/mWGQpO/1kOAe85JCGP4IPSt6GZvqJacMgEoXmS8blVV5QL S0t8p5jBcCM8ca8B906bIgevkf0sRpa7XZA4yHHiO+pEO0uisYL77FNfnFtor9sPq/87 PwGUQVpiGq0wqh1NH50v19aDZ7nZg8HClf0HLaP/2b1awOx9Yri4qqfE+BcLvUTCPYjB lQOX9cQ02tSX5k+jJOYyGnNHZJLMWo3/Z65l5O9zk9WW9fE3yFfSHAy5ia9npVOLyxjX uB+MZMcOvdH5oUQIzgXkOfDmcWdgZsM0rUKyDSvZ9m7UFBCJSfSfYOc77W6HK8M9Uz7Q xRAw== X-Gm-Message-State: AOJu0Yw9+y6Ce7b+e+FGtzK15D2UVptcYFnUbQpkmnvHzP/6qalCgGvk CEwRVUW5ywfNoj9zhTheek2CxrkiwJ8= X-Google-Smtp-Source: AGHT+IHIEoJ5Qp0cT7058FSDnFlcgu0NfKZ+k2cnwo0UQE0i+ifeNt8ssvIZEJlieWuqLdMggeWcLX6T9W4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:4cf:b0:d7b:92d7:5629 with SMTP id v15-20020a05690204cf00b00d7b92d75629mr82335ybs.8.1694824312956; Fri, 15 Sep 2023 17:31:52 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:08 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-17-seanjc@google.com> Subject: [PATCH 16/26] KVM: MIPS: Stop adding virt/kvm to the arch include path From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173154_974731_EDED3289 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Don't add virt/kvm to KVM MIPS' include path, the headers in virt/kvm are intended to be used only by other code in virt/kvm, i.e. are "private" to the core KVM code. It's not clear that MIPS *ever* included a header from virt/kvm, i.e. odds are good the "-Ivirt/kvm" was copied from a different architecture's Makefile when MIPS support was first added. Signed-off-by: Sean Christopherson --- arch/mips/kvm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kvm/Makefile b/arch/mips/kvm/Makefile index 805aeea2166e..96a7cd21b140 100644 --- a/arch/mips/kvm/Makefile +++ b/arch/mips/kvm/Makefile @@ -4,7 +4,7 @@ include $(srctree)/virt/kvm/Makefile.kvm -ccflags-y += -Ivirt/kvm -Iarch/mips/kvm +ccflags-y += -Iarch/mips/kvm kvm-$(CONFIG_CPU_HAS_MSA) += msa.o From patchwork Sat Sep 16 00:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF21BCD37B1 for ; Sat, 16 Sep 2023 00:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0zD1+eVffCNfcXElZqHFL6+iXegiN+IPVEsb4GIA+Mg=; b=KzLtseZKBk6L/b QxxE/eEtdwgEo8WPB78FwTOIjwM/RUYCl1Ase9SUvDsHjbUWb9BXW2GPdE5+CwqC6jNUR7PljpFad /aLiYsiS5D69xb9N1uztvdlTQiN07JpRIpzeW/uQ9q4tK/uYdywPXGg7PZcpCyTg4KJwh7sZxB5if zTVUXLTjmpvfs6ax9EzAusoPyknphsf6q2OStxnKyCVV6xxbFDo/ypsUPmcTZloE645q2PvP4swPO d8RnFA7l64pRalvAkUhofsvu7J1Xvzuma6PMXuYFsNzALnZCTpHHLO41gJJmfR03KaiZPfkotUV3H MaLkL0Z13pSjyijovm7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJFl-00BeVO-0I; Sat, 16 Sep 2023 00:33:41 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE8-00Bcyj-1s for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PzobvpQc4vWfR42iy4RjYEgAb/kHLuzC5INLwcS+RqY=; b=f8ihytYxFeydf39g9xKvpBiXdF UU5DcZurmUDOBPSWnhdNSxezPcxo/ppBHdELFow3auFDvA74IE/Ig38RDlgvfgzG1ubpsKTxpb4JX QZe5YvETln/hZ/Zw7bjaMQacS6c0VYmcMVcd89c3uH1BEPksEqQUJc3rW/iTDR1H2KNsvnpsKUk83 lNAPked2j6jclt5F1S/iPnM9rDUGrqqENsHS5dcVfeCnAwvHWoDpu5qQOSlutJ4/N66eHBak3JvF+ Njw85SSaLn9U0LTAl6lf5EqZED2fl4ZoMUVj0UYdQMefKLOUgOYZb+zvYCg4X24FoMhUfegU/rEJJ 8QESPyGA==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE3-009jpj-1z for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:31:58 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58c8b2d6784so34339937b3.3 for ; Fri, 15 Sep 2023 17:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824315; x=1695429115; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=PzobvpQc4vWfR42iy4RjYEgAb/kHLuzC5INLwcS+RqY=; b=Cwz60IBh7+h00iMqdibbVDV+aj9UEQhYdkyQbUodv5GfjMyU5emAsQvaMsNgCnP06F vPmA2Ii/phEnYUKbepTebPaaO9WI/kGX3ojn6Z9DOHl2Ypo+izb9/hRIBT+1NukV1pry JVdPXMsb9O2iZbeI1xEYeMJPVkxahV8Wp+Jelx4XxDUxpq5K5jLBgpx3DVFaRKkWTMYU B3zLwpxhLvR2ABu8extRHT9G8HeIUBbjs+dJ5d5QxcheC7BWmRDmv3ykYgH9OQR49KfS UzYrb3byjBh9W5SN/pPdNZ5xpfxsixnlqvI0nTfbDVl75agV4m7y+diy41P201k+m8G+ ntoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824315; x=1695429115; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PzobvpQc4vWfR42iy4RjYEgAb/kHLuzC5INLwcS+RqY=; b=t4BkjUNIn/RWiaQsKIx9sf4XkxpLIHB23wtTQ0hpmn60ykTbzuNBGldLQuu4ECKlnD f9QqK/YREXTLJLJf3LDKFxmP4/CdnzUwJADM/dabdBpZyZFjc2SLfkhrlYNHCS6b4T9a dB81Qp3UKF3yhBLukH+ryidIKtN0/JiVbBlsRPsZyfboxJ0X/IX2Y4OiOKM+pyduQBGk fyEukxmOyC11Q2fE7U9/ordjBswkvXTLER9CjzprIViwx1akKC2FL3NIR+BZz14uSxa3 uBhyDBp8lLlIzv9TJgrIiSNqgE3NuLDRev3O0OYbEKo/Muk4E3LgEhUcKHlO6zuII9Sw zglw== X-Gm-Message-State: AOJu0YxSPSX/I7ZG7ZbMWiHdsTtBKaLGw2pNrJNLfbf3x3kKptH+M6xb 0XsA47IyMd3cIAv8K/0LfMsV8zC00KM= X-Google-Smtp-Source: AGHT+IEHyBaVn0yDFSDy5XyxKJ2PGYyocUtrZpuSTqYnDVflp7SqStNr9ZpB4/OYXqxtlzASuEez5Ye4vGU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2e06:0:b0:d77:fb4e:d85e with SMTP id u6-20020a252e06000000b00d77fb4ed85emr78448ybu.6.1694824314795; Fri, 15 Sep 2023 17:31:54 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:09 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-18-seanjc@google.com> Subject: [PATCH 17/26] KVM: PPC: Stop adding virt/kvm to the arch include path From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013157_311138_C65907F8 X-CRM114-Status: GOOD ( 11.55 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Don't add virt/kvm to KVM PPC's include path, the headers in virt/kvm are intended to be used only by other code in virt/kvm, i.e. are "private" to the core KVM code. It's not clear that PPC *ever* included a header from virt/kvm, i.e. odds are good the "-Ivirt/kvm" was copied from a different architecture's Makefile when PPC support was first added. Signed-off-by: Sean Christopherson --- arch/powerpc/kvm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index 5319d889b184..08a0e53d58c7 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -3,7 +3,7 @@ # Makefile for Kernel-based Virtual Machine module # -ccflags-y := -Ivirt/kvm -Iarch/powerpc/kvm +ccflags-y := -Iarch/powerpc/kvm include $(srctree)/virt/kvm/Makefile.kvm From patchwork Sat Sep 16 00:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B840FCD37AF for ; Sat, 16 Sep 2023 00:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fs5emjntms/bKPsKKfJ3JLyva1PHp/dQ2Y51bT0A2bk=; b=YdHfk5+Td2oX91 JECfbol3pINyiU8fiiJYi/IUUOEJlbfltkDJu3fifgoIB5fueAErHxGRoLghBsdYfiZ96rNV79wt5 H/mqRAWQNb97s4pL+JynRT0WyH536KEuDnEuG6yA+/bzFpHmHI7yfiDFSWAgNW2cQuEgYcFqZ/+hR JnF1Hv+8btf85dIKAvYEO2UK7P124KH6fcztPK+tB7A7YmFfPU/bHYRO2jamI7XZa94aRZ0+og7To Neq9lyhzaxS/AvL5dipT6rXxHKaoHi5HZu0r4O82oBcY3YZXRPdKbkuhON+jyfov9iLUqxwAurjuB NVFcxj0uJcNfg33QKLqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGC-00BesR-1R; Sat, 16 Sep 2023 00:34:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEB-00Bd2L-14 for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Fxp/wpw1LF0d8Fhe/2GDyJ/jS0kdkc80zXgNVrZkdeA=; b=ix+ZbfoJ2lAOHqBBtCHd3tzo4E iMbBliSUh9hXlVggjiiqzDFcynAArfnhzqNBnJWkN47ajHWwxfL88n9Ufbx3Q8uPP7nNw+0r/N9QX 0CeY/2sudnXDgjS6oU1mURaFigF5LY7af9SX6/N3kc2fq9ErUCyuELevq6HDVdHUCjCClPPygCemc R3Kl4Qwm9veUr7tAVsLgCim1/MeSS/czCopd29I0xRqiyPF9mTLM0nVPnEUgezTTp4jbZnioIKfLR mo57ZEMo0rBRx5oCAQi3+uMap/hsfnjaD3ppANAoTJTaOy7NYzJSjB/RSAjxoJoYAvAwp8KTBBuwN TEOG3e5A==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE5-009jqS-2y for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:01 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d81d85aae7cso2236569276.0 for ; Fri, 15 Sep 2023 17:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824317; x=1695429117; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=Fxp/wpw1LF0d8Fhe/2GDyJ/jS0kdkc80zXgNVrZkdeA=; b=IfgdgWhJexViMQv0Yipbvl3d+2TYIyC9MOJGlB8pfUJmagisp8ZUcYN0s1/Nkq/S/W kkpvbm2jhSXjPiFEUwrymXwvsDzQEHSRpMbEdv4/E6OASH6eW6tNtgKoqpkF0ptIocsn EcxRiv6Y3SlOkaTYb0laAYYzHW4/HZ8i605js1KosCfJBEUBZ4b6E1o6vdPX8VyzY41L tQ+f8Tck3Cql52XacHomDOXalEriAVmePrRMD1Ke5ofI0h20+4C9MJpUft4aIHLlARtp Ry0/8ak2voVqPawvCuAm7Q/NdISz+KL7Fh0rj6/41xiGIUj7Ldh3T0LMiuD4KbYHZtI4 bM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824317; x=1695429117; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fxp/wpw1LF0d8Fhe/2GDyJ/jS0kdkc80zXgNVrZkdeA=; b=ZbEnm8GizprFIxH7Gz7rU2obJUc+6BpVXqwSJ4Uhxy0dqoqnkz4X1Kk7TE0sOYY2g0 EfZXo8SJcX93hsx8xUcb4TrlHHUflSBDhoMEoR8PUww5sv82K0TKTQGKanL/YnMO5Y0u HJHlHH9GYuOOoPlB79VGtbcBFU8TwA+eBStPpxA1Vj5FcBgiTdMdF5usC8lZksaU+qQB ScKoem9c5WFZv6vIVg0tmlzUfMupqZogbiBShTgNcJxXTb3NPaYlCB/qZgtVBC+KHrH2 EHVvFf3zO792ZQKPp8p2/6eFkLYStwovIAbx+b9ZY/q1dYlNRUgAqPR9TBSlAwvL+Run 2JaQ== X-Gm-Message-State: AOJu0Yxubar1L8qEMLzW5mwNlts8Rfr3oLJTo6zW8pP02J36eYtwD7EP aXnbZhR9zt0k7fLFTGr0q6208nFR10U= X-Google-Smtp-Source: AGHT+IEqdj0NaTPFhwcZwboCYWpv5WyTfAkaUyiX867J7n21mAe+KnDvjijo+FbZ8yrF1vPesmLGFCOD+Os= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:4444:0:b0:d80:8aa6:5ac0 with SMTP id r65-20020a254444000000b00d808aa65ac0mr190245yba.4.1694824316815; Fri, 15 Sep 2023 17:31:56 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:10 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-19-seanjc@google.com> Subject: [PATCH 18/26] KVM: s390: Stop adding virt/kvm to the arch include path From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013159_728495_3F39F0C6 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Don't add virt/kvm to KVM s390's include path, the headers in virt/kvm are intended to be used only by other code in virt/kvm, i.e. are "private" to the core KVM code. It's not clear that s390 *ever* included a header from virt/kvm, i.e. odds are good the "-Ivirt/kvm" was copied from a x86's Makefile when s390 support was first added. The only headers in virt/kvm at the time were the x86 specific ioapic.h, and iodev.h, neither of which shows up as an #include in the diff for the commit range 37817f2982d0f..e976a2b997fc4. Signed-off-by: Sean Christopherson Reviewed-by: Thomas Huth Acked-by: Claudio Imbrenda --- arch/s390/kvm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index 02217fb4ae10..f17249ab2a72 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -5,7 +5,7 @@ include $(srctree)/virt/kvm/Makefile.kvm -ccflags-y := -Ivirt/kvm -Iarch/s390/kvm +ccflags-y := -Iarch/s390/kvm kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o From patchwork Sat Sep 16 00:31:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FE3ACD37B2 for ; Sat, 16 Sep 2023 00:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n3pUrbEynQ7nFJ3jtrEIVplKdUE/CTm+C2U2Mdijvr4=; b=XGxdJXasyYn8VL ysx5nR4LaAGEkF+ozR5PuMKAWDXvExCx7zqzXX2vY1/z8K5clzzq8mX1kOIj+376+AA3K6osv7Skj +OjRx+1CqaxiIwuaUW6fqagpt0wqm8+dMCrlLja5zP/uaPLFlQA5mldhALUfM+2FaFeRaM7dSZi6Q f+SsS5IWxb928BgQtSSZxad3RLcW10AlF8mShXQ7ZcKn6mZPpZxN1vh/XVBuBhSkUByY96ZVYzgkB 2SefWuwrlgocG96KWJ7pP72IhFd25J+etdSmQ9Ceo3f4IA5340M0G6R9cGEJCp6lez/VMczGoytKv 9Y0tKm7MA7wLaGab8zTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGL-00Bf04-1O; Sat, 16 Sep 2023 00:34:17 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJED-00Bd52-1x for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=I1k7UlFLK1e3KB496SGnrZE1fwTPdTtkvkYnZUVfXtU=; b=OwnLQE4fP/feA992zKoAMzseXW 9fusg3uynvfpYxC+bQjm8znyux2bEJ984gjFnJ+LQcQCtM1Qr9+T2DPsuY1ALREILy4i3/uckfN3P HJu6gJfacsSvkNw36crpd7JHG5MshG7DHz32QDJmq+GkE25KqGph030YHZaSM6QCZW2N2M0Jiw00I vKclraAbI8DDXbIhhJ8th8CZNsIV72yG8sR/KdSZsXiMM807jV/rFke+QTPDCTDrSkdG2dRVqAg6W qtyjdxYyhonmQKGeyHY/Uy/0nqXflUQFK/9fVhhGP1OZLCAybInBYd69wIolbW/hfvwX427hQoUZv UmmRyvsQ==; Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJE7-009jqg-1w for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:03 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c41538c7eeso21087935ad.1 for ; Fri, 15 Sep 2023 17:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824318; x=1695429118; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=I1k7UlFLK1e3KB496SGnrZE1fwTPdTtkvkYnZUVfXtU=; b=LninouIESa0KhCQ7s2s7e/7/Wi4jcjxaKK3DmhL0tk+25q/r2EeGx0NW5FhYePynRq N3YRKoIRggHCBrqjwPhEUgqraXu28OJD+pNPvv2qF5kYMyviCfO6Cb+xalO2ErzcGv6h Aj0Uh9n6QC0GPHnD6X8l/99e7soXL3+7HwFKbfXJHpZoeQFBx2UQnaXzF/F5YO+EtAiQ Wr24Xtf2N1LXRMh2+voWnsvDbvnwX78rA1Z3pMdg0CGEPi/TFQ/JcT+BR4J5pequjwX1 rxGo/0sWGvh5aLeeTXR830QnC/N7iBDHC5TE0gNe4OCfJ6r5f94Tp2tqGOy8v/G7koV+ KGug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824318; x=1695429118; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I1k7UlFLK1e3KB496SGnrZE1fwTPdTtkvkYnZUVfXtU=; b=a9ojzH2GlJu+pB7D2cYU8QEo7F/TER+JrmTwjSs617nO6Hnht0ma7nKSsSFKs0pDNn Df1ih2QyBCWWUAUGSm2+FtQX4r5fsbwutoTIcsDGJchiLAP1xL7wjF3UJNPlhLKhEQxo EZD8QaAFNyBo3aCofIqW0g8LBSE7UvNpSMuojENKxFtpG96BKT9Y51BfvFF/eKJD1sLS xWT1wpGYfHFc1g9yAorO5cijZakelUNGUaO0yqRUIItZA7VJ2eoyhgs9SQLXey2K6JRO 5gwN49e8Rujw2zQ5ovpVndHUrzynqu/uD04yMkvMTqo8QL5J6v75Lhdn8pmqZ8lqmE0O wIFA== X-Gm-Message-State: AOJu0YzyuOid2xrk0AAQsuQWCI/2AgUlQGtO+qBcv4BOjFT2v9/pV9LS gxewDbW7f7iKMQDBS3CniNETmy4qvx8= X-Google-Smtp-Source: AGHT+IFCF5MUMD869yhPhgA85k1sz5CoJq/QTd908FyvX67dvIc3xBcuRDs8mX3N7g5mT6MCs9yGRfwK12c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ec8b:b0:1bf:cc5:7b53 with SMTP id x11-20020a170902ec8b00b001bf0cc57b53mr68748plg.1.1694824318653; Fri, 15 Sep 2023 17:31:58 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:11 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-20-seanjc@google.com> Subject: [PATCH 19/26] KVM: Standardize include paths across all architectures From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013201_824030_E5D79C4E X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Standardize KVM's include paths across all architectures by declaring the KVM-specific includes in the common Makefile.kvm. Having common KVM "own" the included paths reduces the temptation to unnecessarily add virt/kvm to arch include paths, and conversely if allowing arch code to grab headers from virt/kvm becomes desirable, virt/kvm can be added to all architecture's include path with a single line update. Having the common KVM makefile append to ccflags also provides a convenient location to append other things, e.g. KVM-specific #defines. Note, this changes the behavior of s390 and PPC, as s390 and PPC previously overwrote ccflags-y instead of adding on. There is no evidence that overwriting ccflags-y was necessary or even deliberate, as both s390 and PPC switched to the overwrite behavior without so much as a passing mention when EXTRA_CFLAGS was replaced with ccflags-y (commit c73028a02887 ("s390: change to new flag variable") and commit 4108d9ba9091 ("powerpc/Makefiles: Change to new flag variables")). Signed-off-by: Sean Christopherson Acked-by: Anup Patel --- arch/arm64/kvm/Makefile | 2 -- arch/mips/kvm/Makefile | 2 -- arch/powerpc/kvm/Makefile | 2 -- arch/riscv/kvm/Makefile | 2 -- arch/s390/kvm/Makefile | 2 -- arch/x86/kvm/Makefile | 1 - virt/kvm/Makefile.kvm | 2 ++ 7 files changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index c0c050e53157..3996489baeef 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -3,8 +3,6 @@ # Makefile for Kernel-based Virtual Machine module # -ccflags-y += -I $(srctree)/$(src) - include $(srctree)/virt/kvm/Makefile.kvm obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/mips/kvm/Makefile b/arch/mips/kvm/Makefile index 96a7cd21b140..d198e1addea7 100644 --- a/arch/mips/kvm/Makefile +++ b/arch/mips/kvm/Makefile @@ -4,8 +4,6 @@ include $(srctree)/virt/kvm/Makefile.kvm -ccflags-y += -Iarch/mips/kvm - kvm-$(CONFIG_CPU_HAS_MSA) += msa.o kvm-y += mips.o emulate.o entry.o \ diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index 08a0e53d58c7..d6c6678ddf65 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -3,8 +3,6 @@ # Makefile for Kernel-based Virtual Machine module # -ccflags-y := -Iarch/powerpc/kvm - include $(srctree)/virt/kvm/Makefile.kvm common-objs-y += powerpc.o emulate_loadstore.o diff --git a/arch/riscv/kvm/Makefile b/arch/riscv/kvm/Makefile index 4c2067fc59fc..ff7d5f67e229 100644 --- a/arch/riscv/kvm/Makefile +++ b/arch/riscv/kvm/Makefile @@ -3,8 +3,6 @@ # Makefile for RISC-V KVM support # -ccflags-y += -I $(srctree)/$(src) - include $(srctree)/virt/kvm/Makefile.kvm obj-$(CONFIG_KVM) += kvm.o diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile index f17249ab2a72..f8153189e003 100644 --- a/arch/s390/kvm/Makefile +++ b/arch/s390/kvm/Makefile @@ -5,8 +5,6 @@ include $(srctree)/virt/kvm/Makefile.kvm -ccflags-y := -Iarch/s390/kvm - kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 80e3fe184d17..d13f1a7b7b3d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y += -I $(srctree)/arch/x86/kvm ccflags-$(CONFIG_KVM_WERROR) += -Werror ifeq ($(CONFIG_FRAME_POINTER),y) diff --git a/virt/kvm/Makefile.kvm b/virt/kvm/Makefile.kvm index 29373b59d89a..e85079ad245d 100644 --- a/virt/kvm/Makefile.kvm +++ b/virt/kvm/Makefile.kvm @@ -3,6 +3,8 @@ # Makefile for Kernel-based Virtual Machine module # +ccflags-y += -I$(srctree)/$(src) + KVM ?= ../../../virt/kvm kvm-y := $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/binary_stats.o From patchwork Sat Sep 16 00:31:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6271CD37B2 for ; Sat, 16 Sep 2023 00:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1ihWou7NYTW4dGjQggE0OqT4+asUl5cMkP9QxdtO5aU=; b=YObnbZWH8uDdei wML51iLq5piX5t/LzxxNIXYLRRECAch95e7u49b1yGO5cqKMSUSy19/p57opSRp3SevrIljXwM1hb ir6gTnkPMQ150Xlf69z6p5dA2lSJySkJeGKuPPnIqTztn88os7qW4k0kBA2TEARzttwMteoMp/Tyq K7bLuT1NyTMdkQNcC3Ttl4M1fzSu00Ju4DYAJ7TIvHKK9KZGHtB4frFz3HhcD9Xf90eAoTVGbhsCj vmfAYrIpUewDMMRq3bZTsNwjBSPfrkgMZ5igB9UvZnjVi1kPkBKb+zNuDp6fiv2+82qPhEjeF7uiA 9P6vIwfbTTLZUHYH6DVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGU-00Bf9x-08; Sat, 16 Sep 2023 00:34:26 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEG-00Bd8E-1v for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B1dRB8XO+KspaRMyC7zp9UYo9xj54whk7JRM1+EstQc=; b=CP1v4n2P56nVYhEd9Ciz9upwzw i77a1kcF4t2FfzB5IdQDytjJ3C7D5zO39Q2/TYp3g4QFBtabpzITqa5+vR2MXCrc3ifg5vtrpFmcN hVHNhYWRbaPXrFx/iZxZjjhKtdGt4EYtGK+XCZdQO3uY7nTH0Ju9R5bLqN5JLIGXsR0zHvYbNWNLt o7lbgbQbO2zxgedRdvgA90Hlv8bSCIJ87J1n5ssjoFoAtNofp1jkRuZ/PeW3c8NOMGhqDidQC5NAe 4cDGBNaq/vYnxdX7hGelIuCqTMUzndw2eEem6e6ZCzCxuMn9bSX5QpHZ1Mq1YcyIN4wHDPDvEiwqg S1Z+DzWg==; Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEA-009jsY-1x for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:06 +0000 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-56f89b2535dso2528689a12.2 for ; Fri, 15 Sep 2023 17:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824321; x=1695429121; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=B1dRB8XO+KspaRMyC7zp9UYo9xj54whk7JRM1+EstQc=; b=ppv8foM9ee6IjseFHBBEPEVc/ld6lFbSZsuqZuRotu0mCLZoUlBDIAvcAU6f59owbr PrnuV0HcX+np+cukoC6pH+2QY4K2adEa/ukPgY8BDb/7PgqwKU+hVBf4BPWijDTliuxC 3tTSJ2f2zQlysd4mf7wEM+cSapYjMgOewyfG0jhGaZRoYu22Ga1d+C5YurWwQV0XAmUc WK66dCR7bQWHI4b0k25YKbcizzaQrTpyZOtvCFHmfFvkZb4Yxga7OPtlQXIblk7eUltO J/ZeysjVKI+P0zxDKcuxYoqHnWR1IyObe+7oJTo/ll8CSnvjywaX1wFK5MATtPlXFgfS 9iCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824321; x=1695429121; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=B1dRB8XO+KspaRMyC7zp9UYo9xj54whk7JRM1+EstQc=; b=TPlrJ0UAsGwE5lOJH67+m6flW+Fr+zkk64sIYtgtIIUNCsykR44YVqLxwwGp3Dspwd UkKS9f7grhcCPcy6ab89hmE+AylNqcsDUAH4ZuIm8c3BwK7M3HpR+bX+k8wLqiDbp4/I aYodIudk4ZDvuIrFaGGCC84eBNrvH8/KzjXAryLKF6+N6dRIjMdM1lRPWXKtECcfzn65 kGbRvu68f5wYCHExcK6l53uxKlnK7GdVc8IfPl0eoiOeULs3IimrolrVY5HmyvrGjGn+ FS2Ui/xDbZTT3j907WNiqkvOaOD9Uh6E5qp6VIL9hSJK6Pd6iCdzr7Q73ktlBUAttEgC r8ZA== X-Gm-Message-State: AOJu0YwZoZXGzNQpRbWKK8uLtXRMSCIBRdK2Ne8bB6m2hYYW03oWHH+K IvAZqR8yfTT3OjTrvVFcEdr6N4DWuok= X-Google-Smtp-Source: AGHT+IEG3geNQyBEinQ/Gc8L0qGg6gjLTemmwswG1GJ9AY1G6CN5uqCE+2kqm1oXbdjIn4d5e6QeKtFd3X4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:7057:0:b0:574:535:60f with SMTP id a23-20020a637057000000b005740535060fmr69376pgn.11.1694824320845; Fri, 15 Sep 2023 17:32:00 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:12 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-21-seanjc@google.com> Subject: [PATCH 20/26] perf/x86: KVM: Have perf define a dedicated struct for getting guest PEBS data From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013204_630335_787EA681 X-CRM114-Status: GOOD ( 23.88 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Have perf define a struct for getting guest PEBS data from KVM instead of poking into the kvm_pmu structure. Passing in an entire "struct kvm_pmu" _as an opaque pointer_ to get at three fields is silly, especially since one of the fields exists purely to convey information to perf, i.e. isn't used by KVM. Perf should also own its APIs, i.e. define what fields/data it needs, not rely on KVM to throw fields into data structures that effectively hold KVM-internal state. Signed-off-by: Sean Christopherson --- arch/x86/events/core.c | 5 +++-- arch/x86/events/intel/core.c | 18 +++++++++--------- arch/x86/events/perf_event.h | 3 ++- arch/x86/include/asm/kvm_host.h | 9 --------- arch/x86/include/asm/perf_event.h | 12 ++++++++++-- arch/x86/kvm/vmx/pmu_intel.c | 16 +++++++++++++--- arch/x86/kvm/vmx/vmx.c | 10 ++++++---- arch/x86/kvm/vmx/vmx.h | 2 +- 8 files changed, 44 insertions(+), 31 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 185f902e5f28..3b015cfcf41d 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -695,9 +695,10 @@ void x86_pmu_disable_all(void) } } -struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data) +struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, + struct x86_guest_pebs *guest_pebs) { - return static_call(x86_pmu_guest_get_msrs)(nr, data); + return static_call(x86_pmu_guest_get_msrs)(nr, guest_pebs); } EXPORT_SYMBOL_GPL(perf_guest_get_msrs); diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index fa355d3658a6..9b848d7ebaaf 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -4053,11 +4052,11 @@ static int intel_pmu_hw_config(struct perf_event *event) * when it uses {RD,WR}MSR, which should be handled by the KVM context, * specifically in the intel_pmu_{get,set}_msr(). */ -static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) +static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, + struct x86_guest_pebs *guest_pebs) { struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); struct perf_guest_switch_msr *arr = cpuc->guest_switch_msrs; - struct kvm_pmu *kvm_pmu = (struct kvm_pmu *)data; u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl); u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable; int global_ctrl, pebs_enable; @@ -4090,20 +4089,20 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) return arr; } - if (!kvm_pmu || !x86_pmu.pebs_ept) + if (!guest_pebs || !x86_pmu.pebs_ept) return arr; arr[(*nr)++] = (struct perf_guest_switch_msr){ .msr = MSR_IA32_DS_AREA, .host = (unsigned long)cpuc->ds, - .guest = kvm_pmu->ds_area, + .guest = guest_pebs->ds_area, }; if (x86_pmu.intel_cap.pebs_baseline) { arr[(*nr)++] = (struct perf_guest_switch_msr){ .msr = MSR_PEBS_DATA_CFG, .host = cpuc->active_pebs_data_cfg, - .guest = kvm_pmu->pebs_data_cfg, + .guest = guest_pebs->data_cfg, }; } @@ -4119,8 +4118,8 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) arr[pebs_enable].guest = 0; } else { /* Disable guest PEBS thoroughly for cross-mapped PEBS counters. */ - arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask; - arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask; + arr[pebs_enable].guest &= ~guest_pebs->cross_mapped_mask; + arr[global_ctrl].guest &= ~guest_pebs->cross_mapped_mask; /* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */ arr[global_ctrl].guest |= arr[pebs_enable].guest; } @@ -4128,7 +4127,8 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) return arr; } -static struct perf_guest_switch_msr *core_guest_get_msrs(int *nr, void *data) +static struct perf_guest_switch_msr *core_guest_get_msrs(int *nr, + struct x86_guest_pebs *guest_pebs) { struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); struct perf_guest_switch_msr *arr = cpuc->guest_switch_msrs; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index c8ba2be7585d..d805c9007e35 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -920,7 +920,8 @@ struct x86_pmu { /* * Intel host/guest support (KVM) */ - struct perf_guest_switch_msr *(*guest_get_msrs)(int *nr, void *data); + struct perf_guest_switch_msr *(*guest_get_msrs)(int *nr, + struct x86_guest_pebs *guest_pebs); /* * Check period value for PERF_EVENT_IOC_PERIOD ioctl. diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 1a4def36d5bb..29db870dbaae 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -548,15 +548,6 @@ struct kvm_pmu { u64 pebs_data_cfg; u64 pebs_data_cfg_mask; - /* - * If a guest counter is cross-mapped to host counter with different - * index, its PEBS capability will be temporarily disabled. - * - * The user should make sure that this mask is updated - * after disabling interrupts and before perf_guest_get_msrs(); - */ - u64 host_cross_mapped_mask; - /* * The gate to release perf_events not marked in * pmc_in_use only once in a vcpu time slice. diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index 85a9fd5a3ec3..34c2c9a0b02b 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -564,11 +564,19 @@ static inline void perf_events_lapic_init(void) { } static inline void perf_check_microcode(void) { } #endif +struct x86_guest_pebs { + u64 ds_area; + u64 data_cfg; + u64 cross_mapped_mask; +}; + #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) -extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data); +extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, + struct x86_guest_pebs *guest_pebs); extern void x86_perf_get_lbr(struct x86_pmu_lbr *lbr); #else -struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data); +struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, + struct x86_guest_pebs *guest_pebs); static inline void x86_perf_get_lbr(struct x86_pmu_lbr *lbr) { memset(lbr, 0, sizeof(*lbr)); diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index f2efa0bf7ae8..3b3929871f7e 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -765,11 +765,20 @@ static void intel_pmu_cleanup(struct kvm_vcpu *vcpu) intel_pmu_release_guest_lbr_event(vcpu); } -void intel_pmu_cross_mapped_check(struct kvm_pmu *pmu) +u64 intel_pmu_get_cross_mapped_mask(struct kvm_pmu *pmu) { - struct kvm_pmc *pmc = NULL; + u64 host_cross_mapped_mask; + struct kvm_pmc *pmc; int bit, hw_idx; + if (!(pmu->pebs_enable & pmu->global_ctrl)) + return 0; + + /* + * If a guest counter is cross-mapped to host counter with different + * index, its PEBS capability will be temporarily disabled. + */ + host_cross_mapped_mask = 0; for_each_set_bit(bit, (unsigned long *)&pmu->global_ctrl, X86_PMC_IDX_MAX) { pmc = intel_pmc_idx_to_pmc(pmu, bit); @@ -784,8 +793,9 @@ void intel_pmu_cross_mapped_check(struct kvm_pmu *pmu) */ hw_idx = pmc->perf_event->hw.idx; if (hw_idx != pmc->idx && hw_idx > -1) - pmu->host_cross_mapped_mask |= BIT_ULL(hw_idx); + host_cross_mapped_mask |= BIT_ULL(hw_idx); } + return host_cross_mapped_mask; } struct kvm_pmu_ops intel_pmu_ops __initdata = { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 72e3943f3693..faf0071566ef 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7131,12 +7131,14 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx) struct perf_guest_switch_msr *msrs; struct kvm_pmu *pmu = vcpu_to_pmu(&vmx->vcpu); - pmu->host_cross_mapped_mask = 0; - if (pmu->pebs_enable & pmu->global_ctrl) - intel_pmu_cross_mapped_check(pmu); + struct x86_guest_pebs guest_pebs = { + .ds_area = pmu->ds_area, + .data_cfg = pmu->pebs_data_cfg, + .cross_mapped_mask = intel_pmu_get_cross_mapped_mask(pmu), + }; /* Note, nr_msrs may be garbage if perf_guest_get_msrs() returns NULL. */ - msrs = perf_guest_get_msrs(&nr_msrs, (void *)pmu); + msrs = perf_guest_get_msrs(&nr_msrs, &guest_pebs); if (!msrs) return; diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index c2130d2c8e24..476119670d82 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -670,7 +670,7 @@ static inline bool intel_pmu_lbr_is_enabled(struct kvm_vcpu *vcpu) return !!vcpu_to_lbr_records(vcpu)->nr; } -void intel_pmu_cross_mapped_check(struct kvm_pmu *pmu); +u64 intel_pmu_get_cross_mapped_mask(struct kvm_pmu *pmu); int intel_pmu_create_guest_lbr_event(struct kvm_vcpu *vcpu); void vmx_passthrough_lbr_msrs(struct kvm_vcpu *vcpu); From patchwork Sat Sep 16 00:31:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30EA6CD37B0 for ; Sat, 16 Sep 2023 00:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KPVvAPrtSZpQ+uN6T6D5gqfeHjWda1vvHac7cOOhXK0=; b=JakMd3Qqq7D00r UGRALask8wGPYuy+JR02ZPEc/kquxbV5ICjq2JOuebmquPJuITXyznirDw6zfB69uo528r7GKR/ml 9P3SqgiE83KEGkFIqXSUS+cZ9dY3fv2yVp2szjrGqsh9YhUzxftfG6knC5SogCmYaVEmLVj7NktaW QbyyhDsRCGrsgHOc9bpKLZye4xasZ4np37Wwtz+K7iM49bt6M7mcmnS4MsICz2S3PPB/Vb7f/5gqw QSNGhZW1PiISgl0bVJ1by39bSts6qBnk/tV+7aY79qlcIIkkddi/n9PuuK/90m7fOHrGdf1C/EkOX bB/6l7Ips1DgItMBVjIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGR-00Bf6C-0q; Sat, 16 Sep 2023 00:34:23 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEC-00Bd3O-28 for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:09 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59c12d31d04so12968097b3.1 for ; Fri, 15 Sep 2023 17:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824323; x=1695429123; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=kZSgVl8Q+hmlGcu9E42B+6nCYbsSFCH4k+E/cwlLEa8=; b=Kt3hlIXqw3efHDA0Y+qA3OWfblVgjo3swNseeHFIZC9u+cvlRssqJOrnQQNm5g6+7I kU4DGUXOah2DjmPExDjtcdYb9hLLtTBGNSnVatcDXz4p9zmx5UK0lYilhy56LXEWYQEk 3un42rxZcm6wOkgtUVHw934HU9hx9C5awH7FMWTiAyw+2BKXEppsIv3w+80Qongo80gz ulDVVwVnrknzteKaQMrgdVkE+/OsZ8rnxJziHSxxwODeslJvosvHQhEJnvSRHI5DOc7d jaRnVzkoIMn7fFdEXTSn+ZV4PvlyW5LpJFGSUpmVeYS71On8ApsYszzdc5sFXht3RIzT guwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824323; x=1695429123; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kZSgVl8Q+hmlGcu9E42B+6nCYbsSFCH4k+E/cwlLEa8=; b=qKmg7Zhyqr2JsPdBUY7JFJHDq+Xph8BdQmVC1FkK8UMMAfdmwmMVbTTFe0nw+iYKJi h2CSZeW6U0oV7bWJREki0qqYE3O2xxR/LpBSVOB7zoNbH0j0FLwLefPnR8MSbdBz+KgX 4VHXJAVCN5HPUpb/U2XYyiVuy5hWL8jKCbQV8gYlR4Wl4Su51SjEhHkeBD63ln7z3fnI eNu9fop5EvsYBHg53zxpZQUWgbEKnbUeZL/2HHGPFN9JWUOKVqhamV+3GYN6lS6gNYaf gAdAbKjeaaCvSRrObncfoj04cvRjbGtbfUitZxiEdUpXTAuvTX//10qL1rthAmT68UiG tHHA== X-Gm-Message-State: AOJu0YyFSuDDGrzPVJsUHEhbW+RkwLl39BXTil2jCKBakjg+hLWKdoLv E9jZaMG48/MtK7Z/mSs7ncr+/WQ8HgE= X-Google-Smtp-Source: AGHT+IGvK90kPH1o5bQH0EPib2Mktorl92L52Xc3vYMLm3HoBq+aka+3/3i87f2Q/TuhX6d+6vnq3Y1BBZw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b60c:0:b0:586:a58d:2e24 with SMTP id u12-20020a81b60c000000b00586a58d2e24mr95790ywh.5.1694824323076; Fri, 15 Sep 2023 17:32:03 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:13 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-22-seanjc@google.com> Subject: [PATCH 21/26] entry/kvm: Drop @vcpu param from arch_xfer_to_guest_mode_handle_work() From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173204_766128_0177F882 X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Drop the "struct kvm_vcpu" parameter from arch_xfer_to_guest_mode_handle_work() as a preparatory step towards removing the vCPU parameter from xfer_to_guest_mode_work() as well. Signed-off-by: Sean Christopherson --- include/linux/entry-kvm.h | 7 ++----- kernel/entry/kvm.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/linux/entry-kvm.h b/include/linux/entry-kvm.h index 6813171afccb..e7d90d06e566 100644 --- a/include/linux/entry-kvm.h +++ b/include/linux/entry-kvm.h @@ -25,18 +25,15 @@ struct kvm_vcpu; /** * arch_xfer_to_guest_mode_handle_work - Architecture specific xfer to guest * mode work handling function. - * @vcpu: Pointer to current's VCPU data * @ti_work: Cached TIF flags gathered in xfer_to_guest_mode_handle_work() * * Invoked from xfer_to_guest_mode_handle_work(). Defaults to NOOP. Can be * replaced by architecture specific code. */ -static inline int arch_xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu, - unsigned long ti_work); +static inline int arch_xfer_to_guest_mode_handle_work(unsigned long ti_work); #ifndef arch_xfer_to_guest_mode_work -static inline int arch_xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu, - unsigned long ti_work) +static inline int arch_xfer_to_guest_mode_handle_work(unsigned long ti_work) { return 0; } diff --git a/kernel/entry/kvm.c b/kernel/entry/kvm.c index 2e0f75bcb7fd..c2fc39824157 100644 --- a/kernel/entry/kvm.c +++ b/kernel/entry/kvm.c @@ -19,7 +19,7 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work) if (ti_work & _TIF_NOTIFY_RESUME) resume_user_mode_work(NULL); - ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work); + ret = arch_xfer_to_guest_mode_handle_work(ti_work); if (ret) return ret; From patchwork Sat Sep 16 00:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4233ECD37B0 for ; Sat, 16 Sep 2023 00:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OkacT3nziv3NkaBfn2Z8E5VT1IfxfZKjxysFDq1/D+Q=; b=OFQAvV9slBCf1b RjRNCuMjWIz67w/ejTA3+DLr648OmpAuhWfCIR1FZaFjsCMsMpWsMvDZQnO8NSPwfmzzNzkrF+lZK Zz3rbeY3BQJtP7BHHKf3trf8tz2DGcvjH59fSnuauNtG8nPneSpC6aCA3yTKhYe6wLrI4XEvYHedM lDnS3kE/ZOAT8py61N+ey1cR6EfPEt/RgbzJCmB7OLO/AdLRexVZUHuJFfQT1/aVhtFr6Jj+ISbsk oe25abfpmFDddR/xw2gY/aJIqHXK/yLc3nUU+ys7vhHEbVcRBpjwJ9iX4sMou2vN5MrPGAo0re0Gl 4eTgaY4DlRGaANDXAxmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGk-00BfRy-2E; Sat, 16 Sep 2023 00:34:42 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEK-00BdCE-0s for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xxhu5mShS80K2/3vPmWMk/nseLaV4p5fitYU0fke5+k=; b=IbLqk1YW2fRp6rRQfgHD8PPHkj CetK8xFH0Ip8nZQhzx/L/9SyCXCeGXheE+zPCvcoQaM447Kt/24td3Y2MlmWzYmvHUAkI2jn1pQ/e Un3hmIvQDTVGvuScoBqqBX0KOZc49ftk3dNaaa4FGfhQdd5iUpMqfF2ReFJqguAA1PipcP5IkIVvH q8IIMtOCiAS36fHajrEP1SgGSiApq9DwxnFkBhQtmuyHXn2nNfwYdDBvV5m729aN0yTahDTsnBxgC PmFBaV54MEl5D65qw8+bKp97ibJk4pcWhKHjBfbvX+/iypRCagC9722+Zdrmv3iuGsagcrCC6zK+n dy3xKPLw==; Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEE-009jtx-2N for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:10 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59b5a586da6so52660357b3.1 for ; Fri, 15 Sep 2023 17:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824325; x=1695429125; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=xxhu5mShS80K2/3vPmWMk/nseLaV4p5fitYU0fke5+k=; b=O5dSK34zTjrJXi22YWe/d91Qb7hIXlRYiAS1mFdGDLY69KCY4zFOqufmliOUxALPZm dQUqHleBenkyLLLmwbsQhC0xfobY/7tyQVjkKa5N3+7CeTvLLora4dVHzyRc5NSz/MKJ MaWD3u9rmM+l8dBmLKZi8qIXFhp8iEX4MHQ2XwIe41hvq3KYu8+sWNe9HTAeqbRMycV9 dsMinkRxFWdUP57XV3PK6FLllVfF0Tyykptd/XfMCe/98M/dT5PJ1IIoMCNUXJpzytej mjY8JGs43MILWSYEP7o5wHSfb4Cw6z24IvIEwz0eDM5THaDhIfkCjdVugmLJOll3xjB2 3Daw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824325; x=1695429125; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xxhu5mShS80K2/3vPmWMk/nseLaV4p5fitYU0fke5+k=; b=ceDuoxpwx78ixz/dsq0LnnEhTpkGvGUCl8flXcGOH2Jbc3Xtx4X6FOzPHD4zS/PpDB K2+V2UXeuH9STE22+6UUACax0BMPyOVxQx/uqgXAWw2DXPvHOxRg9cPvmyIcFJcQAZHZ gWnhd6QtED/IyfhScbcIVinl0B1x97Y3nXzHCVZBJNzI925uU72Nww66Cr2jAeNWJN8e /KUc4xYNrSINO5XacwcH3LQPSKlYJC8O9y3pkb+eW3BtVTnQ9YEJu+zPO8Johiso6n8Q 0laB+THctCcAjdgBXqOWJ2sIbVY2DBlBXev0CeMlrPZa8dNZogkQrCgMx67bPhrSfzcj 8rvw== X-Gm-Message-State: AOJu0YwfpReoWskb7rYXqdAiG20u+Pq2HPmgSm/X6c06L3EpKwGIn46u xFdILvOexE+TcvEkGhMDEoZN9pWhuQE= X-Google-Smtp-Source: AGHT+IFivAqBzULaKYZ+rdlM5WV3p7FxezM4z6b9SH0+UFxp1erLN5VtiAhqE4c7vi4i2igDi9x6k3utDco= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:2f05:b0:589:a533:405b with SMTP id ev5-20020a05690c2f0500b00589a533405bmr205315ywb.3.1694824325035; Fri, 15 Sep 2023 17:32:05 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:14 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-23-seanjc@google.com> Subject: [PATCH 22/26] entry/kvm: KVM: Move KVM details related to signal/-EINTR into KVM proper From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013208_311663_AC625BBB X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move KVM's morphing of pending signals into exits to userspace into KVM proper, and drop the @vcpu param from xfer_to_guest_mode_handle_work(). How KVM responds to -EINTR is a detail that really belongs in KVM itself, and removing the non-KVM call to kvm_handle_signal_exit() will allow hiding said API and the definition of "struct kvm_vcpu" from the kernel. Alternatively, entry/kvm.c could be treated as part of KVM, i.e. be given access to KVM internals, but that's not obviously better than having KVM react to -EINTR (though it's not obviously worse either). Signed-off-by: Sean Christopherson --- arch/arm64/kvm/arm.c | 3 +-- arch/riscv/kvm/vcpu.c | 2 +- arch/x86/kvm/vmx/vmx.c | 1 - arch/x86/kvm/x86.c | 3 +-- include/linux/entry-kvm.h | 3 +-- include/linux/kvm_host.h | 13 ++++++++++++- kernel/entry/kvm.c | 11 ++++------- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 6480628197b4..641df091e46b 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -929,7 +928,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) /* * Check conditions before entering the guest */ - ret = xfer_to_guest_mode_handle_work(vcpu); + ret = kvm_xfer_to_guest_mode_handle_work(vcpu); if (!ret) ret = 1; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 82229db1ce73..c313f4e90e70 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -667,7 +667,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) run->exit_reason = KVM_EXIT_UNKNOWN; while (ret > 0) { /* Check conditions before entering the guest */ - ret = xfer_to_guest_mode_handle_work(vcpu); + ret = kvm_xfer_to_guest_mode_handle_work(vcpu); if (ret) continue; ret = 1; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index faf0071566ef..43b87ad5fde8 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6c9c81e82e65..aab095f89d9e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include @@ -10987,7 +10986,7 @@ static int vcpu_run(struct kvm_vcpu *vcpu) if (__xfer_to_guest_mode_work_pending()) { kvm_vcpu_srcu_read_unlock(vcpu); - r = xfer_to_guest_mode_handle_work(vcpu); + r = kvm_xfer_to_guest_mode_handle_work(vcpu); kvm_vcpu_srcu_read_lock(vcpu); if (r) return r; diff --git a/include/linux/entry-kvm.h b/include/linux/entry-kvm.h index e7d90d06e566..e235a91d28fc 100644 --- a/include/linux/entry-kvm.h +++ b/include/linux/entry-kvm.h @@ -42,11 +42,10 @@ static inline int arch_xfer_to_guest_mode_handle_work(unsigned long ti_work) /** * xfer_to_guest_mode_handle_work - Check and handle pending work which needs * to be handled before going to guest mode - * @vcpu: Pointer to current's VCPU data * * Returns: 0 or an error code */ -int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu); +int xfer_to_guest_mode_handle_work(void); /** * xfer_to_guest_mode_prepare - Perform last minute preparation work that diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index fb6c6109fdca..d520d6801070 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -2,7 +2,7 @@ #ifndef __KVM_HOST_H #define __KVM_HOST_H - +#include #include #include #include @@ -2293,6 +2293,17 @@ static inline void kvm_handle_signal_exit(struct kvm_vcpu *vcpu) vcpu->run->exit_reason = KVM_EXIT_INTR; vcpu->stat.signal_exits++; } + +static inline int kvm_xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu) +{ + int r = xfer_to_guest_mode_handle_work(); + + if (r) { + WARN_ON_ONCE(r != -EINTR); + kvm_handle_signal_exit(vcpu); + } + return r; +} #endif /* CONFIG_KVM_XFER_TO_GUEST_WORK */ /* diff --git a/kernel/entry/kvm.c b/kernel/entry/kvm.c index c2fc39824157..872617468b4a 100644 --- a/kernel/entry/kvm.c +++ b/kernel/entry/kvm.c @@ -1,17 +1,14 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include -static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work) +static int xfer_to_guest_mode_work(unsigned long ti_work) { do { int ret; - if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) { - kvm_handle_signal_exit(vcpu); + if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) return -EINTR; - } if (ti_work & _TIF_NEED_RESCHED) schedule(); @@ -28,7 +25,7 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work) return 0; } -int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu) +int xfer_to_guest_mode_handle_work(void) { unsigned long ti_work; @@ -44,6 +41,6 @@ int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu) if (!(ti_work & XFER_TO_GUEST_MODE_WORK)) return 0; - return xfer_to_guest_mode_work(vcpu, ti_work); + return xfer_to_guest_mode_work(ti_work); } EXPORT_SYMBOL_GPL(xfer_to_guest_mode_handle_work); From patchwork Sat Sep 16 00:31:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9058FCD37B0 for ; Sat, 16 Sep 2023 00:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WQ/5Mx9TirlHrtBBTX/SMQXiqn8u+tVdXiv6YlsF9V0=; b=NbGgHEr7gDXajY rBfe2Ikpxw6BazrFgQbvywVbepc4YYaS9dsXIZ7PnQ//wfNxkJ2PeoMxE4zIwQ853b+WlCMCu2HZJ MhfBuks/5nXGzkfCom2DSfevii9uiyRpTjehGYoKfHBEINrgqZSMdrjxzvgdoJN5DmT7Da6xgnw9/ YbWkoY0rTga9lFwcz2v9OcBQp9u72g1PHkTmWxLtu28PKk0OdkCBpBzaqsMX6ZPshqDBGd3c33lMo 9G2mMqVDhEQlIXQlMZp/S95SxI/Bfp0ld+zaVMckv4fQs4iMEZJ9S+7BPrKB57R6YxcJqybml07PH fXoNxKcV9GdxizgrFULQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGo-00BfVn-0H; Sat, 16 Sep 2023 00:34:46 +0000 Received: from mail-yb1-f202.google.com ([209.85.219.202]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEI-00Bd7u-0x for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:16 +0000 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d7b957fd276so3276376276.0 for ; Fri, 15 Sep 2023 17:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824327; x=1695429127; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=g87cF9aMFFIIQhALNgZyjDSNT/0Iy7aXKR5wCizfY2Q=; b=bu6bG/xQph3dS3elJuDNyCsbzE6caFlxcfxcIM7kc2JdNNaSZTTQs+tkGmg+X5EQfp pUCaqUXuBdBs8fahr4y083gpCosmKHHwPvNr6qKYNg71jeBoAaQN9s4QmYL1xN7QhxTd 6K6wCJIwwo+bAWZue8LJ0edmElc25OlDtsP6/eU9YiMhV1+sanfyMe1hyZ0CgCb5Vpj7 qosvRFElG5X/8ynEC9vFiSbicYVsyvDyUOsVv/+StWQwz7O6R+5jxR6qEgbVhivEcn8v azU83ioFydLOUW0jPAcfjf14yiEzyD31ev71Fw5zSODvo58C6ESiqJo+3HFBbms44Cae m+wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824327; x=1695429127; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g87cF9aMFFIIQhALNgZyjDSNT/0Iy7aXKR5wCizfY2Q=; b=EE/JkQeCIwzyArfNEkcyc8l1/OKD55/xd0eilS+l4U2zdFWprIJ+wuM6o1f3XrEQ69 3eQOxIzZ4f2Qq1mxBzD5ONNfx2hO++2FsZqXDpwEd1O1RSuMmMqMGzOCwAehtYMTzOyI Kwbi0/CZIO3sq8K3o9b98K7pBu/H2jZJQ7iws5iyyqntN2hwpDfWzv+LtulDkXKSwPym ngO12J7joNV6AAzggWezJuZm05tpCszqQ2R53lvwvYsZVpTDB9guWoYbaVkeg6ntNQtS fNJ4IpSHx1Zk2j36rOTL3ETPm7KQLbijPSu2GzOxNl+6Fnk6ejBPIElVxAuyMZNYUVez Qzkg== X-Gm-Message-State: AOJu0YxBTgNZFYUGx59UAOISHsPA06M4FuyuJflqfR0owzYmN8GFYP6t XCR5eBuL2jPuAe0FA+lnnfkR+RaaQIc= X-Google-Smtp-Source: AGHT+IFjtTFMkJb5nyS/TbDu5WGvlim/mDgHE3y34bDt9PwwLEa+gj6fWVowFGkCoq7czWyFJVVkIfy0aAQ= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:d28b:0:b0:d0c:c83b:94ed with SMTP id j133-20020a25d28b000000b00d0cc83b94edmr70330ybg.10.1694824326852; Fri, 15 Sep 2023 17:32:06 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:15 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-24-seanjc@google.com> Subject: [PATCH 23/26] KVM: arm64: Move and consolidate "public" functions in asm/kvm_host.h From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173210_378361_8821657B X-CRM114-Status: GOOD ( 11.51 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move a variety of "public" symbols in arm64's kvm_host.h, i.e. symbols and functions that are used by non-KVM code, towards the top of the header. This will allow hiding the "private" code in kvm_host.h, i.e. the stuff that is intended to be KVM-internal, with a minimal amount of #ifdeffery. Signed-off-by: Sean Christopherson --- arch/arm64/include/asm/kvm_host.h | 48 ++++++++++++++----------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 90cfbf420545..89b40c34f0af 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -67,10 +67,32 @@ enum kvm_mode { }; #ifdef CONFIG_KVM enum kvm_mode kvm_get_mode(void); + +extern phys_addr_t hyp_mem_base; +extern phys_addr_t hyp_mem_size; +void __init kvm_hyp_reserve(void); + +void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr); +void kvm_clr_pmu_events(u32 clr); +bool kvm_set_pmuserenr(u64 val); #else static inline enum kvm_mode kvm_get_mode(void) { return KVM_MODE_NONE; }; + +static inline void kvm_hyp_reserve(void) { } + +static inline void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr) {} +static inline void kvm_clr_pmu_events(u32 clr) {} +static inline bool kvm_set_pmuserenr(u64 val) +{ + return false; +} #endif +static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr) +{ + return (!has_vhe() && attr->exclude_host); +} + DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use); extern unsigned int __ro_after_init kvm_sve_max_vl; @@ -1086,28 +1108,10 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu); void kvm_vcpu_unshare_task_fp(struct kvm_vcpu *vcpu); -static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr) -{ - return (!has_vhe() && attr->exclude_host); -} - /* Flags for host debug state */ void kvm_arch_vcpu_load_debug_state_flags(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_put_debug_state_flags(struct kvm_vcpu *vcpu); -#ifdef CONFIG_KVM -void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr); -void kvm_clr_pmu_events(u32 clr); -bool kvm_set_pmuserenr(u64 val); -#else -static inline void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr) {} -static inline void kvm_clr_pmu_events(u32 clr) {} -static inline bool kvm_set_pmuserenr(u64 val) -{ - return false; -} -#endif - void kvm_vcpu_load_sysregs_vhe(struct kvm_vcpu *vcpu); void kvm_vcpu_put_sysregs_vhe(struct kvm_vcpu *vcpu); @@ -1142,14 +1146,6 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu); (test_bit(KVM_ARCH_FLAG_HAS_RAN_ONCE, &(kvm)->arch.flags)) int kvm_trng_call(struct kvm_vcpu *vcpu); -#ifdef CONFIG_KVM -extern phys_addr_t hyp_mem_base; -extern phys_addr_t hyp_mem_size; -void __init kvm_hyp_reserve(void); -#else -static inline void kvm_hyp_reserve(void) { } -#endif - void kvm_arm_vcpu_power_off(struct kvm_vcpu *vcpu); bool kvm_arm_vcpu_stopped(struct kvm_vcpu *vcpu); From patchwork Sat Sep 16 00:31:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC22BCD37B2 for ; Sat, 16 Sep 2023 00:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0cnjOUY1P32Rjc17+RxiAm7vZZOMd8mgmQ2OL+fg69I=; b=jqUYwwXQYmOIZS RvXrNEEc5k9xtDR3f+wrRG6HJewfUqmf+VBOOPLA3tJwC1LkySvt8Q/SwNpnwabxYPUaFnoAAUOdC LCS/jRuxyoPA+D2qskCeL4+72Y1RIskjokJlje1RHyLJmiZx6Fdv7iwhM6aE3JJQoJrEYqS+4R/8J i9B91HAO6exrqLGwx4RhwlXJ7flT995JptPtLXXGSW0u6Ace3zbmaeZrDQjO3VQWjIWIt9z+Lu267 +/ZkZwWQRh4hGl5WDFxHMLk/EPiYQmjhiex1RoiJGLwP+wwNFRM7TrN5CB74ADo8IiE5MmFrL/BKk 5MoprQPPvB6AuV3wcphA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJGt-00BfcH-34; Sat, 16 Sep 2023 00:34:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJER-00BdIv-0E for linux-riscv@bombadil.infradead.org; Sat, 16 Sep 2023 00:32:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0VtgUtus3LRehL4neqp1OYPW/02VDjf+LHA0REetHQw=; b=pdzWXnEvH+qjIs2j7xeypTX1rg qIlocvRfb4PAqRDqHnDMAmr5pGXKWpAWNYy1pe/M1bkDj5Ed0O4qo1AgrEIjoS1m3iE78rZha+bDD 7WaJaoWBUXZa9emdccNnm9kGaipj1E40tuwd7jxqr+Z1+LFDTk2bJN95S1qp7JOeeUews43TGAPSG rdCMzF2xfeVxO9gTAfnSvpm6aExjrDQQBiLPKMjRpIe3wqEJylTjhqr87AWzlcfgjOMbJDOfZf8EY vUc6UtxlHhdyvnBdymLtcakvL2A4i2fTJflz1zyVq5lEcLPWVnkQrpIG5JzZcN2d5lBUNb5VnHSTJ YoC2RHjA==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEH-009jv5-2u for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:14 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b6a51f360so33312107b3.1 for ; Fri, 15 Sep 2023 17:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824329; x=1695429129; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=0VtgUtus3LRehL4neqp1OYPW/02VDjf+LHA0REetHQw=; b=gjUhE0vNMgu2uJGQH+peDOUYhVf06S++4j6/2jkon6ZZY6jozUCL0TMyMp/b0c560r GIp1h7bYZXtFFFp19Y5rhsMrfD/E8+XMxMm7foxJUnGBQWQfN9HdIsB9wfiz6qkAZ+V3 mvzWn+ziSoTvlt7bfUYOzVzDvmtn4+cb/wWGdTy4WJhkDhZnVnfKAaVJmnQlSiBKEXkN My7qZyvU4zikjudzJSBg/NPoYOtJgJmtz/qbLzJPgsQ8yjbFxz+VMLResWyxmGik/Ug9 BK+xGEnG2U6eBUgkJf/JYft7+olqSKQACX1dCW4vPttFBW/6SYtQ+V4myMQGxqje7Jcs dD7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824329; x=1695429129; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0VtgUtus3LRehL4neqp1OYPW/02VDjf+LHA0REetHQw=; b=SyCG74UZnisrqJWb88JzYpoJCvZN5ff6R8VgObglEp8OFJi+w4RN2g9NvGXkkVYyUd jtCkxE7rJorYIFxVVU/qz8SGxvXHXfNhJEDmYdHVYOixMHKNAEIhLEqXdDhsLVI+tqPq 5Z5EwieQAmF111k9rZq+0QySsSNb3EhesGTQ1Fsz/VfWKTJ4izLMCpqimvYMPvoKUoga hGXANym7WGwqzMCHnoFUAlxJbLjYMPcXVZxG3AqOD5COTuFi/xbuSaHO0TAB4TFKfmv0 m9r0e5aOUAMU+t4YpqPiMNu8PjOi/Yat+0nP6JgXngUbPsOpKXxbeVOIts9/8zg447YC hI2A== X-Gm-Message-State: AOJu0YyXMTMIB03vFZax51CoivefFdGuOv2a6ejf7nr+kAHy+NFR6EXu MC0w/xVXH0g+k8rXsFc0td5haXuMfn0= X-Google-Smtp-Source: AGHT+IGS7sQUeRqIzboGgj+JmfOv6SrnKFoWg2KC/khh+vzWzgZdEe9LRtHGjdK8tkWZSSHoGr6LIc8WFow= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b620:0:b0:58c:a9b4:a64c with SMTP id u32-20020a81b620000000b0058ca9b4a64cmr86672ywh.1.1694824328926; Fri, 15 Sep 2023 17:32:08 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:16 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-25-seanjc@google.com> Subject: [PATCH 24/26] powerpc/xics: Move declaration of xics_wake_cpu() out of kvm_ppc.h From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230916_013211_506251_13479036 X-CRM114-Status: GOOD ( 11.48 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org xics_wake_cpu() is provided by core PPC code, not by KVM. Move its declaration out of kvm_ppc.h and into xics.h. Signed-off-by: Sean Christopherson --- arch/powerpc/include/asm/kvm_ppc.h | 2 -- arch/powerpc/include/asm/xics.h | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index b4da8514af43..72fee202d3ec 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -1072,6 +1072,4 @@ static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) return ea; } -extern void xics_wake_cpu(int cpu); - #endif /* __POWERPC_KVM_PPC_H__ */ diff --git a/arch/powerpc/include/asm/xics.h b/arch/powerpc/include/asm/xics.h index 89090485bec1..17a45c022bd9 100644 --- a/arch/powerpc/include/asm/xics.h +++ b/arch/powerpc/include/asm/xics.h @@ -32,6 +32,9 @@ extern int icp_native_init(void); extern void icp_native_flush_interrupt(void); extern void icp_native_cause_ipi_rm(int cpu); +#ifdef CONFIG_SMP +extern void xics_wake_cpu(int cpu); +#endif #else static inline int icp_native_init(void) { return -ENODEV; } #endif From patchwork Sat Sep 16 00:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48CC3CD37B2 for ; Sat, 16 Sep 2023 00:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0NW8GwVLX1b0wLZmCfTEdLZILYl6ab9MGNormHPdIQk=; b=z1d1Iuj+KWVplG 1abDUlw7vUinUz4ht7294bJBLawZrRYXVvMqMbC2m4anxTnTQgBw8LP5NFMJBFOJPM7ep8Sc3oEPT XyivzJNbNh4H9t23iH0vwg+9xkGDzUtwUWcFirqttfT0kXr2vkn22WuAr6dZQU49fNg/vVH82lA13 710atslPzP0dKeaf3fHg+vUh3MmggJFf6cejR+/47Ce7+TduqAtWy2Y0eQQjiFCEsGp/6yPfCdCR8 f3zkvIrO6vHR7/RbgiZOQ9cPEtp4M+/xFuYuJNtgBAC6opAMfqNQ3LUClMD9DQuzIxoQRn92SHf/w dm4oPRIjugx6XTmxSJLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJH1-00Bfk3-1e; Sat, 16 Sep 2023 00:34:59 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEK-00BdCC-2Z for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:20 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c43cd8b6cbso8826005ad.0 for ; Fri, 15 Sep 2023 17:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824331; x=1695429131; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=XQKt9ip81eNaA/ioPgL3dH9e9vr3TzqljSeTBinzyVo=; b=HKFaO/z1aovNw9JDYBNXAKNxuubxdqbOmFVe7xwzyP3z1uatkSJlDU9LyQ1+Sa0yO7 9FHtgvZ5wMLqwRL5cxScMSdJttb/aHRgzlXAgAY9FB9zz3wK2DZDXgSsMkI2D/GRrFUV IMQroFfyeYk8vUhlQ6AN2JMkBnZVMiIBlEiL6dXqBFKkD/fphjLlzBH6CdIxzzjJtuBb jGh5L73RSEiI6YFid5txS+B61re4kXxlew9P0kshNLmshx0+69g0ykZ47M1Bjy7yhrTm 9SmBWBodyxKJyyHXe4+32mMKZvWI5/XECvyhUGRe4Bnixz+i55wqhS1msJc0GvisFX9D Affg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824331; x=1695429131; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XQKt9ip81eNaA/ioPgL3dH9e9vr3TzqljSeTBinzyVo=; b=RTEGiY+YFhQI/++yiV2bNiInH6ZLJyInC0qog2cEjVXdGAbquefBF0IJvH1nBWv4u4 eG1sMoORaEFAEeNn/3UOPuCtgBt8D2r/xnmi6pSOuuSZaS0AwLm3tWP26OgF7Y1xUTst GFFudNkZjgXU5izSkxvPQeznKED7MeIImOBRNLv30pK6yPWytn2uQtCBgomiVg3oLq80 u0C6KdrcAtWJLT+MQgYtDxEnYFC2E0MqfuGGFyKQ48OeUHvGcg4BVseHKPqqo6toM6TK ALAE74Wz/FMCGAX142KaFVU7l3K4RFA3t7ojjnXachwHYijr7L1ajfizL6DI+Sdr3P/T jBUQ== X-Gm-Message-State: AOJu0Yy5ODdyplxRQGebeApqn+EoPcQGnqF5jD/Od+D9ZFwvTop/7Ud5 DXR6rFE9JQFV6oatZLrdNCEXRKYcLkk= X-Google-Smtp-Source: AGHT+IGF/tpivhdzzMxCzu4p2COJ/tsujORVDRvqtMyofX9ypz/OjlCrOXRz/aOj6KmZJ7FZTcTX3ecEuUc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:d4c7:b0:1bc:5182:1de2 with SMTP id o7-20020a170902d4c700b001bc51821de2mr81466plg.1.1694824330917; Fri, 15 Sep 2023 17:32:10 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:17 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-26-seanjc@google.com> Subject: [PATCH 25/26] KVM: PPC: Rearrange code in kvm_ppc.h to isolate "public" information From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173212_921302_A8EF6FBF X-CRM114-Status: GOOD ( 19.78 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move all declarations and definitions in kvm_ppc.h that are consumed by things other than KVM to the top of the file. This will allow wrapping the parts of kvm_ppc.h that are intended only for KVM, i.e. are intended to be "private" to KVM, with an #ifdef to hide KVM's internal details from the kernel at-large. Signed-off-by: Sean Christopherson --- arch/powerpc/include/asm/kvm_ppc.h | 302 +++++++++++++++-------------- 1 file changed, 153 insertions(+), 149 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 72fee202d3ec..ead2ad892ebc 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -30,6 +30,159 @@ #endif #include +struct openpic; + +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE +extern void kvm_cma_reserve(void) __init; +static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) +{ + paca_ptrs[cpu]->kvm_hstate.xics_phys = (void __iomem *)addr; +} + +static inline void kvmppc_set_xive_tima(int cpu, + unsigned long phys_addr, + void __iomem *virt_addr) +{ + paca_ptrs[cpu]->kvm_hstate.xive_tima_phys = (void __iomem *)phys_addr; + paca_ptrs[cpu]->kvm_hstate.xive_tima_virt = virt_addr; +} + +static inline u32 kvmppc_get_xics_latch(void) +{ + u32 xirr; + + xirr = get_paca()->kvm_hstate.saved_xirr; + get_paca()->kvm_hstate.saved_xirr = 0; + return xirr; +} + +/* + * To avoid the need to unnecessarily exit fully to the host kernel, an IPI to + * a CPU thread that's running/napping inside of a guest is by default regarded + * as a request to wake the CPU (if needed) and continue execution within the + * guest, potentially to process new state like externally-generated + * interrupts or IPIs sent from within the guest itself (e.g. H_PROD/H_IPI). + * + * To force an exit to the host kernel, kvmppc_set_host_ipi() must be called + * prior to issuing the IPI to set the corresponding 'host_ipi' flag in the + * target CPU's PACA. To avoid unnecessary exits to the host, this flag should + * be immediately cleared via kvmppc_clear_host_ipi() by the IPI handler on + * the receiving side prior to processing the IPI work. + * + * NOTE: + * + * We currently issue an smp_mb() at the beginning of kvmppc_set_host_ipi(). + * This is to guard against sequences such as the following: + * + * CPU + * X: smp_muxed_ipi_set_message(): + * X: smp_mb() + * X: message[RESCHEDULE] = 1 + * X: doorbell_global_ipi(42): + * X: kvmppc_set_host_ipi(42) + * X: ppc_msgsnd_sync()/smp_mb() + * X: ppc_msgsnd() -> 42 + * 42: doorbell_exception(): // from CPU X + * 42: ppc_msgsync() + * 105: smp_muxed_ipi_set_message(): + * 105: smb_mb() + * // STORE DEFERRED DUE TO RE-ORDERING + * --105: message[CALL_FUNCTION] = 1 + * | 105: doorbell_global_ipi(42): + * | 105: kvmppc_set_host_ipi(42) + * | 42: kvmppc_clear_host_ipi(42) + * | 42: smp_ipi_demux_relaxed() + * | 42: // returns to executing guest + * | // RE-ORDERED STORE COMPLETES + * ->105: message[CALL_FUNCTION] = 1 + * 105: ppc_msgsnd_sync()/smp_mb() + * 105: ppc_msgsnd() -> 42 + * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored + * 105: // hangs waiting on 42 to process messages/call_single_queue + * + * We also issue an smp_mb() at the end of kvmppc_clear_host_ipi(). This is + * to guard against sequences such as the following (as well as to create + * a read-side pairing with the barrier in kvmppc_set_host_ipi()): + * + * CPU + * X: smp_muxed_ipi_set_message(): + * X: smp_mb() + * X: message[RESCHEDULE] = 1 + * X: doorbell_global_ipi(42): + * X: kvmppc_set_host_ipi(42) + * X: ppc_msgsnd_sync()/smp_mb() + * X: ppc_msgsnd() -> 42 + * 42: doorbell_exception(): // from CPU X + * 42: ppc_msgsync() + * // STORE DEFERRED DUE TO RE-ORDERING + * -- 42: kvmppc_clear_host_ipi(42) + * | 42: smp_ipi_demux_relaxed() + * | 105: smp_muxed_ipi_set_message(): + * | 105: smb_mb() + * | 105: message[CALL_FUNCTION] = 1 + * | 105: doorbell_global_ipi(42): + * | 105: kvmppc_set_host_ipi(42) + * | // RE-ORDERED STORE COMPLETES + * -> 42: kvmppc_clear_host_ipi(42) + * 42: // returns to executing guest + * 105: ppc_msgsnd_sync()/smp_mb() + * 105: ppc_msgsnd() -> 42 + * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored + * 105: // hangs waiting on 42 to process messages/call_single_queue + */ +static inline void kvmppc_set_host_ipi(int cpu) +{ + /* + * order stores of IPI messages vs. setting of host_ipi flag + * + * pairs with the barrier in kvmppc_clear_host_ipi() + */ + smp_mb(); + WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 1); +} + +static inline void kvmppc_clear_host_ipi(int cpu) +{ + WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 0); + /* + * order clearing of host_ipi flag vs. processing of IPI messages + * + * pairs with the barrier in kvmppc_set_host_ipi() + */ + smp_mb(); +} + +extern void kvmppc_xics_ipi_action(void); + +extern void kvm_hv_vm_activated(void); +extern void kvm_hv_vm_deactivated(void); +extern bool kvm_hv_mode_active(void); +#else +static inline void __init kvm_cma_reserve(void) +{} + +static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) +{} + +static inline void kvmppc_set_xive_tima(int cpu, + unsigned long phys_addr, + void __iomem *virt_addr) +{} + +static inline u32 kvmppc_get_xics_latch(void) +{ + return 0; +} + +static inline void kvmppc_set_host_ipi(int cpu) +{} + +static inline void kvmppc_clear_host_ipi(int cpu) +{} + +static inline bool kvm_hv_mode_active(void) { return false; } +#endif + /* * KVMPPC_INST_SW_BREAKPOINT is debug Instruction * for supporting software breakpoint. @@ -443,166 +596,18 @@ void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); struct openpic; #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE -extern void kvm_cma_reserve(void) __init; -static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) -{ - paca_ptrs[cpu]->kvm_hstate.xics_phys = (void __iomem *)addr; -} - -static inline void kvmppc_set_xive_tima(int cpu, - unsigned long phys_addr, - void __iomem *virt_addr) -{ - paca_ptrs[cpu]->kvm_hstate.xive_tima_phys = (void __iomem *)phys_addr; - paca_ptrs[cpu]->kvm_hstate.xive_tima_virt = virt_addr; -} - -static inline u32 kvmppc_get_xics_latch(void) -{ - u32 xirr; - - xirr = get_paca()->kvm_hstate.saved_xirr; - get_paca()->kvm_hstate.saved_xirr = 0; - return xirr; -} - -/* - * To avoid the need to unnecessarily exit fully to the host kernel, an IPI to - * a CPU thread that's running/napping inside of a guest is by default regarded - * as a request to wake the CPU (if needed) and continue execution within the - * guest, potentially to process new state like externally-generated - * interrupts or IPIs sent from within the guest itself (e.g. H_PROD/H_IPI). - * - * To force an exit to the host kernel, kvmppc_set_host_ipi() must be called - * prior to issuing the IPI to set the corresponding 'host_ipi' flag in the - * target CPU's PACA. To avoid unnecessary exits to the host, this flag should - * be immediately cleared via kvmppc_clear_host_ipi() by the IPI handler on - * the receiving side prior to processing the IPI work. - * - * NOTE: - * - * We currently issue an smp_mb() at the beginning of kvmppc_set_host_ipi(). - * This is to guard against sequences such as the following: - * - * CPU - * X: smp_muxed_ipi_set_message(): - * X: smp_mb() - * X: message[RESCHEDULE] = 1 - * X: doorbell_global_ipi(42): - * X: kvmppc_set_host_ipi(42) - * X: ppc_msgsnd_sync()/smp_mb() - * X: ppc_msgsnd() -> 42 - * 42: doorbell_exception(): // from CPU X - * 42: ppc_msgsync() - * 105: smp_muxed_ipi_set_message(): - * 105: smb_mb() - * // STORE DEFERRED DUE TO RE-ORDERING - * --105: message[CALL_FUNCTION] = 1 - * | 105: doorbell_global_ipi(42): - * | 105: kvmppc_set_host_ipi(42) - * | 42: kvmppc_clear_host_ipi(42) - * | 42: smp_ipi_demux_relaxed() - * | 42: // returns to executing guest - * | // RE-ORDERED STORE COMPLETES - * ->105: message[CALL_FUNCTION] = 1 - * 105: ppc_msgsnd_sync()/smp_mb() - * 105: ppc_msgsnd() -> 42 - * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored - * 105: // hangs waiting on 42 to process messages/call_single_queue - * - * We also issue an smp_mb() at the end of kvmppc_clear_host_ipi(). This is - * to guard against sequences such as the following (as well as to create - * a read-side pairing with the barrier in kvmppc_set_host_ipi()): - * - * CPU - * X: smp_muxed_ipi_set_message(): - * X: smp_mb() - * X: message[RESCHEDULE] = 1 - * X: doorbell_global_ipi(42): - * X: kvmppc_set_host_ipi(42) - * X: ppc_msgsnd_sync()/smp_mb() - * X: ppc_msgsnd() -> 42 - * 42: doorbell_exception(): // from CPU X - * 42: ppc_msgsync() - * // STORE DEFERRED DUE TO RE-ORDERING - * -- 42: kvmppc_clear_host_ipi(42) - * | 42: smp_ipi_demux_relaxed() - * | 105: smp_muxed_ipi_set_message(): - * | 105: smb_mb() - * | 105: message[CALL_FUNCTION] = 1 - * | 105: doorbell_global_ipi(42): - * | 105: kvmppc_set_host_ipi(42) - * | // RE-ORDERED STORE COMPLETES - * -> 42: kvmppc_clear_host_ipi(42) - * 42: // returns to executing guest - * 105: ppc_msgsnd_sync()/smp_mb() - * 105: ppc_msgsnd() -> 42 - * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored - * 105: // hangs waiting on 42 to process messages/call_single_queue - */ -static inline void kvmppc_set_host_ipi(int cpu) -{ - /* - * order stores of IPI messages vs. setting of host_ipi flag - * - * pairs with the barrier in kvmppc_clear_host_ipi() - */ - smp_mb(); - WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 1); -} - -static inline void kvmppc_clear_host_ipi(int cpu) -{ - WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 0); - /* - * order clearing of host_ipi flag vs. processing of IPI messages - * - * pairs with the barrier in kvmppc_set_host_ipi() - */ - smp_mb(); -} - static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) { vcpu->kvm->arch.kvm_ops->fast_vcpu_kick(vcpu); } -extern void kvm_hv_vm_activated(void); -extern void kvm_hv_vm_deactivated(void); -extern bool kvm_hv_mode_active(void); - extern void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu); #else -static inline void __init kvm_cma_reserve(void) -{} - -static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) -{} - -static inline void kvmppc_set_xive_tima(int cpu, - unsigned long phys_addr, - void __iomem *virt_addr) -{} - -static inline u32 kvmppc_get_xics_latch(void) -{ - return 0; -} - -static inline void kvmppc_set_host_ipi(int cpu) -{} - -static inline void kvmppc_clear_host_ipi(int cpu) -{} - static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) { kvm_vcpu_kick(vcpu); } - -static inline bool kvm_hv_mode_active(void) { return false; } - #endif #ifdef CONFIG_PPC_PSERIES @@ -642,7 +647,6 @@ extern u64 kvmppc_xics_get_icp(struct kvm_vcpu *vcpu); extern int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval); extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev, struct kvm_vcpu *vcpu, u32 cpu); -extern void kvmppc_xics_ipi_action(void); extern void kvmppc_xics_set_mapped(struct kvm *kvm, unsigned long guest_irq, unsigned long host_irq); extern void kvmppc_xics_clr_mapped(struct kvm *kvm, unsigned long guest_irq, From patchwork Sat Sep 16 00:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13388025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFDE9CD37B0 for ; Sat, 16 Sep 2023 00:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vUlQ7XC/il2OZI4+LnzVkwQpWbqy4OxPzhgtmwizn8w=; b=1KfDnGQ0jZWe/7 cy8TbPrzCZy0PwHS6TRkc+DNNlbxuwVBeIO1jnq88zB2bKRmgzky1+FHJ/8z3rv0gddrowH0FSUlY NT+5JjAbWEIKnTf+3ARf1jSI0+6vOPGbEqsLEi6bsmlb1h6blQmVTWvuXxqtYONu8AeHAhevZbwUo QRpE1xbKCod6ZtqBY8x6T2zhN+08tq4DrYi94l6F1EUIawu2Q5VxdMXZ4KdSjVMgVVun8EiCl4+NH gRweH7YA4I9HROgEB6lADeWfti+0Xe0NQlOomWvAllWx0/gN90KXmpJSQHTbXr2jOIqcQYrKmQfP/ lEca7sPb8141q/dM0nzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhJHB-00BfuI-1o; Sat, 16 Sep 2023 00:35:09 +0000 Received: from mail-yb1-f201.google.com ([209.85.219.201]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhJEN-00BdEp-1z for linux-riscv@lists.infradead.org; Sat, 16 Sep 2023 00:32:27 +0000 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d81873bf443so2899979276.1 for ; Fri, 15 Sep 2023 17:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694824333; x=1695429133; darn=lists.infradead.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:from:to:cc:subject:date :message-id:reply-to; bh=KxFx3Fi7YuxuIuavK7ybnF2fqrq2iHl6ALoFtRauezE=; b=ijm5TrjWpi3vjrI3IKCXAILZ3L/jv2u/geVe97kdBIuXeE0wyyH1xiNCiFMEk7eUwW 2v+lNssRTFdzRTsUn2/e7fL8vapPxKmj7MTSeUB3Z4yWIxuObD7VSnCw+8HXtgGGeYEt 27NHrYglzp0iM4bjWj7mGQ5xFMEelr1grSj8v6sK0MMCBoNrxOjc6I9jticfS19TwtM0 qXRpGHMxNlzH1gaHypdxxiRAsUOMDtj42I4cZ2ebnco/PIuJU+cU661DXeDaePu6w4Bc V9lSu1xKCaAjAN5/fQ/jEX5jUoGEGCWJfTnY8q4vxRq0dWw1OAPyxBEkCjs2ZIY12wsS EMoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694824333; x=1695429133; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=KxFx3Fi7YuxuIuavK7ybnF2fqrq2iHl6ALoFtRauezE=; b=P7m7BUepjMhMWkMsdFblSVKbKkoyolpBT9tnPC1CEA2JUUwhU7FZDitRTB8vlB5Pfi +mpJXCsCVg10AGbsvP5MgpQzbJYFFDjaQNPwAqlYcZ+5HL8bKsHq53IBmtPLolNS+Mp4 z9wJ2PElgrTUdGnV2jTyyEcorzrjWPBnXRi8rle9d1Y098LXIuo5nZgZEWlGCeqDl6da TY2i1O8hSEzk7X1qnoFOrMthizmWFPOwhfyI2sbM6dI5MvN4htgkPIcmB3H14DREDqhv ZpLWpDyMVlot0MXpeoBWouNLXGnYy8jf9xvhLozdEV+DhHOR9sIzwPC3twcT+KktD5x3 nU3A== X-Gm-Message-State: AOJu0YyJmrle+qr/8qkLjcnBCWsdKsyAG1+Nyl2WYak2X2/Gu49Bgxhz VNBH/GmdhhYKSfMIHA/c+Jx66JaxoNc= X-Google-Smtp-Source: AGHT+IEXzS/r4n0jWXYqmldfe2JXkH8I7F6JhHKmdXW7QQez9wS/RPm4WWzKr0H7Mg/fmcjRSnqE67DRs+k= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:aa24:0:b0:d81:43c7:61ed with SMTP id s33-20020a25aa24000000b00d8143c761edmr78301ybi.5.1694824333108; Fri, 15 Sep 2023 17:32:13 -0700 (PDT) Date: Fri, 15 Sep 2023 17:31:18 -0700 In-Reply-To: <20230916003118.2540661-1-seanjc@google.com> Mime-Version: 1.0 References: <20230916003118.2540661-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230916003118.2540661-27-seanjc@google.com> Subject: [PATCH 26/26] KVM: Hide KVM internal data structures and values from kernel at-large From: Sean Christopherson To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Peter Zijlstra , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini , Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Alex Williamson , Andy Lutomirski Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Anish Ghulati , Venkatesh Srinivas , Andrew Thornton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230915_173215_695140_F4C32C59 X-CRM114-Status: GOOD ( 25.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Wrap all KVM internal APIs, data structures, values, etc. in public headers with "#ifdef __KVM__" to effectively hide KVM's internal details from other subsystems and the kernel at-large. Hiding KVM details for all architectures will, in the very distant future, allow loading a new (or old) KVM module without needing to rebuild and reboot the entire kernel, or to even allow loading and running multiple versions of KVM simultaneously on a single host. To allow different instances of KVM modules to freely modify KVM data structures, enums, #defines, etc., e.g. the struct kvm_vcpu layout, there must be exactly zero dereferences of KVM-defined structures/values in non-KVM code (excepting code for architectures that don't support such shenanigans). Any such references could lead to latent bugs, e.g. as the kernel would think a KVM structure has layout X, but in reality the current incarnation of KVM uses layout Y. In KVM x86, all remaining non-KVM references to KVM details have been now eliminated. To harden KVM against new references being introduced, hide KVM's details to ensure that KVM doesn’t create a de facto ABI with the rest of the kernel. Use #ifdeffery to hide KVM details as doing so requires, by far, the least amount of churn and impact on architectures that freely share select KVM details with the rest of the kernel, e.g. s390, ARM64 and PPC, have significant usage of KVM-defined APIs, structures, values, etc. E.g. attempting to extract the "private" chunks into dedicated KVM-internal headers would require massive churn, even on x86, and it's not obvious the end result would be a net positive (all attempts at moving code around failed long before getting anywhere near compiling cleanly). Another (bad) alternative that would be relative churn-free would be to move the KVM headers to a dedicated KVM-specific path while maintaining the generic layout, e.g. something like virt/kvm/include/linux. That would allow x86 to simply omit the KVM-specific include path. But that would require modifying the global include path, i.e. would make KVM a really special snowflake and set the awful precedent that it's "ok" to add subsystem specific directories to the global include path. Grant exceptions to asm-offsets.c as needed, and to s390's VFIO AP driver. Creating a KVM-specific asm-offsets, as was done for x86, adds no value (x86 did so to avoid exposing vendor specific headers) and doesn't create much of a "slippery slope" risk. s390's VFIO AP driver on the other hand is simply too intertwined with KVM to realistically treat it as anything other than KVM code, despite it living in crypto drivers, e.g. the driver has some rather crazy lock ordering rules between the device and KVM. Add a static assert that __KVM__ is defined in trace/events/kvm.h, as that is effectively a private KVM header that just happens to live in a public path. Shuffle a few PPC includes and an s390 declaration as needed, and opportunistically include kvm_host.h in trace/events.kvm.h instead of relying on the parent to provide the right includes. Cc: Anish Ghulati Cc: Venkatesh Srinivas Cc: Andrew Thornton Signed-off-by: Sean Christopherson --- arch/arm64/include/asm/kvm_emulate.h | 3 +++ arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/include/asm/kvm_mmu.h | 4 ++++ arch/arm64/kernel/asm-offsets.c | 2 ++ arch/arm64/kvm/hyp/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/Makefile | 3 ++- arch/arm64/kvm/hyp/vhe/Makefile | 2 +- arch/mips/include/asm/kvm_host.h | 2 ++ arch/mips/kernel/asm-offsets.c | 2 ++ arch/powerpc/include/asm/kvm_book3s.h | 3 +++ arch/powerpc/include/asm/kvm_book3s_64.h | 2 ++ arch/powerpc/include/asm/kvm_booke.h | 4 ++++ arch/powerpc/include/asm/kvm_host.h | 7 ++++--- arch/powerpc/include/asm/kvm_ppc.h | 2 ++ arch/powerpc/kernel/asm-offsets.c | 1 + arch/riscv/include/asm/kvm_host.h | 3 +++ arch/riscv/kernel/asm-offsets.c | 1 + arch/s390/include/asm/kvm_host.h | 7 +++++-- arch/s390/kernel/asm-offsets.c | 1 + arch/x86/include/asm/kvm_host.h | 3 +++ drivers/s390/crypto/vfio_ap_drv.c | 1 + drivers/s390/crypto/vfio_ap_ops.c | 2 ++ include/linux/kvm_host.h | 4 ++++ include/linux/kvm_types.h | 3 +++ include/trace/events/kvm.h | 5 +++++ virt/kvm/Makefile.kvm | 2 +- 26 files changed, 64 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index 3d6725ff0bf6..5861fa00763b 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -21,6 +21,8 @@ #include #include +#ifdef __KVM__ + #define CURRENT_EL_SP_EL0_VECTOR 0x0 #define CURRENT_EL_SP_ELx_VECTOR 0x200 #define LOWER_EL_AArch64_VECTOR 0x400 @@ -615,4 +617,5 @@ static __always_inline void kvm_reset_cptr_el2(struct kvm_vcpu *vcpu) kvm_write_cptr_el2(val); } +#endif /* __KVM__ */ #endif /* __ARM64_KVM_EMULATE_H__ */ diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 89b40c34f0af..ba4065db5d5c 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -93,6 +93,7 @@ static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr) return (!has_vhe() && attr->exclude_host); } +#ifdef __KVM__ DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use); extern unsigned int __ro_after_init kvm_sve_max_vl; @@ -1149,4 +1150,5 @@ int kvm_trng_call(struct kvm_vcpu *vcpu); void kvm_arm_vcpu_power_off(struct kvm_vcpu *vcpu); bool kvm_arm_vcpu_stopped(struct kvm_vcpu *vcpu); +#endif /* __KVM__ */ #endif /* __ARM64_KVM_HOST_H__ */ diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 96a80e8f6226..9d8c92cda3b6 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -125,6 +125,8 @@ void kvm_update_va_mask(struct alt_instr *alt, void kvm_compute_layout(void); void kvm_apply_hyp_relocations(void); +#ifdef __KVM__ + #define __hyp_pa(x) (((phys_addr_t)(x)) + hyp_physvirt_offset) static __always_inline unsigned long __kern_hyp_va(unsigned long v) @@ -314,5 +316,7 @@ static inline struct kvm *kvm_s2_mmu_to_kvm(struct kvm_s2_mmu *mmu) { return container_of(mmu->arch, struct kvm, arch); } + +#endif /* __KVM__ */ #endif /* __ASSEMBLY__ */ #endif /* __ARM64_KVM_MMU_H__ */ diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 5ff1942b04fc..dc02ea9a002c 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -7,6 +7,8 @@ * Copyright (C) 2012 ARM Ltd. */ +#define __KVM__ + #include #include #include diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile index 4ce8c86967b5..99982b75671a 100644 --- a/arch/arm64/kvm/hyp/Makefile +++ b/arch/arm64/kvm/hyp/Makefile @@ -5,6 +5,6 @@ incdir := $(srctree)/$(src)/include subdir-asflags-y := -I$(incdir) -I$(srctree)/arch/arm64/kvm -subdir-ccflags-y := -I$(incdir) -I$(srctree)/arch/arm64/kvm +subdir-ccflags-y := -I$(incdir) -I$(srctree)/arch/arm64/kvm -D__KVM__ obj-$(CONFIG_KVM) += vhe/ nvhe/ pgtable.o diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index 2250253a6429..b5f4750fa16e 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -9,7 +9,8 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS # there is no way to execute them and any such MMIO access from nVHE KVM # will explode instantly (Words of Marc Zyngier). So introduce a generic flag # __DISABLE_TRACE_MMIO__ to disable MMIO tracing for nVHE KVM. -ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS -D__DISABLE_TRACE_MMIO__ +ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS \ + -D__DISABLE_TRACE_MMIO__ -D__KVM__ ccflags-y += -fno-stack-protector \ -DDISABLE_BRANCH_PROFILING \ $(DISABLE_STACKLEAK_PLUGIN) diff --git a/arch/arm64/kvm/hyp/vhe/Makefile b/arch/arm64/kvm/hyp/vhe/Makefile index 3b9e5464b5b3..54cd3c444102 100644 --- a/arch/arm64/kvm/hyp/vhe/Makefile +++ b/arch/arm64/kvm/hyp/vhe/Makefile @@ -4,7 +4,7 @@ # asflags-y := -D__KVM_VHE_HYPERVISOR__ -ccflags-y := -D__KVM_VHE_HYPERVISOR__ +ccflags-y := -D__KVM_VHE_HYPERVISOR__ -D__KVM__ obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index f8f63d0aa399..6fd7c998d7b9 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h @@ -25,6 +25,7 @@ #include #include +#ifdef __KVM__ /* MIPS KVM register ids */ #define MIPS_CP0_32(_R, _S) \ (KVM_REG_MIPS_CP0 | KVM_REG_SIZE_U32 | (8 * (_R) + (_S))) @@ -897,4 +898,5 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {} #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS +#endif /* __KVM__ */ #endif /* __MIPS_KVM_HOST_H__ */ diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c index d1b11f66f748..8a233bddfea0 100644 --- a/arch/mips/kernel/asm-offsets.c +++ b/arch/mips/kernel/asm-offsets.c @@ -9,6 +9,8 @@ * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com * Copyright (C) 2000 MIPS Technologies, Inc. */ +#define __KVM__ + #include #include #include diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index bbf5e2c5fe09..8880bc7c8a32 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -13,6 +13,8 @@ #include #include +#ifdef __KVM__ + struct kvmppc_bat { u64 raw; u32 bepi; @@ -483,4 +485,5 @@ static inline u32 kvmppc_pack_vcpu_id(struct kvm *kvm, u32 id) return packed_id; } +#endif /* __KVM__ */ #endif /* __ASM_KVM_BOOK3S_H__ */ diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h index d49065af08e9..a807716ccae6 100644 --- a/arch/powerpc/include/asm/kvm_book3s_64.h +++ b/arch/powerpc/include/asm/kvm_book3s_64.h @@ -16,6 +16,7 @@ #include #include +#ifdef __KVM__ /* * Structure for a nested guest, that is, for a guest that is managed by * one of our guests. @@ -679,4 +680,5 @@ extern pte_t *find_kvm_nested_guest_pte(struct kvm *kvm, unsigned long lpid, #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ +#endif /* __KVM__ */ #endif /* __ASM_KVM_BOOK3S_64_H__ */ diff --git a/arch/powerpc/include/asm/kvm_booke.h b/arch/powerpc/include/asm/kvm_booke.h index 0c3401b2e19e..85ebc0314539 100644 --- a/arch/powerpc/include/asm/kvm_booke.h +++ b/arch/powerpc/include/asm/kvm_booke.h @@ -12,6 +12,8 @@ #include #include +#ifdef __KVM__ + /* * Number of available lpids. Only the low-order 6 bits of LPID rgister are * implemented on e500mc+ cores. @@ -105,4 +107,6 @@ static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu) return false; #endif } + +#endif /* __KVM__ */ #endif /* __ASM_KVM_BOOKE_H__ */ diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 14ee0dece853..1e7a008ce085 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -25,13 +26,14 @@ #include #include #include +#include +#ifdef __KVM__ #define __KVM_HAVE_ARCH_VCPU_DEBUGFS #define KVM_MAX_VCPUS NR_CPUS #define KVM_MAX_VCORES NR_CPUS -#include #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE #include /* for MAX_SMT_THREADS */ @@ -60,8 +62,6 @@ #define KVM_REQ_EPR_EXIT KVM_ARCH_REQ(1) #define KVM_REQ_PENDING_TIMER KVM_ARCH_REQ(2) -#include - #define KVM_ARCH_WANT_MMU_NOTIFIER #define HPTEG_CACHE_NUM (1 << 15) @@ -883,4 +883,5 @@ static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {} static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {} static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {} +#endif /* __KVM__ */ #endif /* __POWERPC_KVM_HOST_H__ */ diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index ead2ad892ebc..03d9998d0111 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -183,6 +183,7 @@ static inline void kvmppc_clear_host_ipi(int cpu) static inline bool kvm_hv_mode_active(void) { return false; } #endif +#ifdef __KVM__ /* * KVMPPC_INST_SW_BREAKPOINT is debug Instruction * for supporting software breakpoint. @@ -1076,4 +1077,5 @@ static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) return ea; } +#endif /* __KVM__ */ #endif /* __POWERPC_KVM_PPC_H__ */ diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 9f14d95b8b32..872d44971536 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -8,6 +8,7 @@ * compile this file to assembler, and then extract the * #defines from the assembly-language output. */ +#define __KVM__ #include #include diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h index 1ebf20dfbaa6..a81ae8c4b739 100644 --- a/arch/riscv/include/asm/kvm_host.h +++ b/arch/riscv/include/asm/kvm_host.h @@ -22,6 +22,8 @@ #include #include +#ifdef __KVM__ + #define KVM_MAX_VCPUS 1024 #define KVM_HALT_POLL_NS_DEFAULT 500000 @@ -354,4 +356,5 @@ bool kvm_riscv_vcpu_has_interrupts(struct kvm_vcpu *vcpu, u64 mask); void kvm_riscv_vcpu_power_off(struct kvm_vcpu *vcpu); void kvm_riscv_vcpu_power_on(struct kvm_vcpu *vcpu); +#endif /* __KVM__ */ #endif /* __RISCV_KVM_HOST_H__ */ diff --git a/arch/riscv/kernel/asm-offsets.c b/arch/riscv/kernel/asm-offsets.c index d6a75aac1d27..476263e78f39 100644 --- a/arch/riscv/kernel/asm-offsets.c +++ b/arch/riscv/kernel/asm-offsets.c @@ -5,6 +5,7 @@ */ #define GENERATING_ASM_OFFSETS +#define __KVM__ #include #include diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index 427f9528a7b6..9153420bb5ac 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -380,6 +380,10 @@ struct sie_page { __u8 reserved700[2304]; /* 0x0700 */ }; +extern char sie_exit; + +#ifdef __KVM__ + struct kvm_vcpu_stat { struct kvm_vcpu_stat_generic generic; u64 exit_userspace; @@ -1028,8 +1032,6 @@ static inline int sie64a(struct kvm_s390_sie_block *sie_block, u64 *rsa) return __sie64a(virt_to_phys(sie_block), sie_block, rsa); } -extern char sie_exit; - bool kvm_s390_pv_is_protected(struct kvm *kvm); bool kvm_s390_pv_cpu_is_protected(struct kvm_vcpu *vcpu); @@ -1049,6 +1051,7 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {} #define __KVM_HAVE_ARCH_VM_FREE void kvm_arch_free_vm(struct kvm *kvm); +#endif /* __KVM__ */ struct zpci_kvm_hook { int (*kvm_register)(void *opaque, struct kvm *kvm); diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index fa5f6885c74a..22ed673871ee 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -6,6 +6,7 @@ */ #define ASM_OFFSETS_C +#define __KVM__ #include #include diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 29db870dbaae..eda45a937666 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -37,6 +37,8 @@ #include #include +#ifdef __KVM__ + #define __KVM_HAVE_ARCH_VCPU_DEBUGFS #define KVM_MAX_VCPUS 1024 @@ -2229,4 +2231,5 @@ int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages); */ #define KVM_EXIT_HYPERCALL_MBZ GENMASK_ULL(31, 1) +#endif /* __KVM__ */ #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c index a5ab03e42ff1..55744f0f4758 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c @@ -7,6 +7,7 @@ * Author(s): Tony Krowiak * Pierre Morel */ +#define __KVM__ #include #include diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 4db538a55192..0dd98f42e9d5 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -8,6 +8,8 @@ * Halil Pasic * Pierre Morel */ +#define __KVM__ + #include #include #include diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d520d6801070..f0afe549c0d6 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -45,6 +45,8 @@ #include #include +#ifdef __KVM__ + #ifndef KVM_MAX_VCPU_IDS #define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS #endif @@ -2329,4 +2331,6 @@ static inline void kvm_account_pgtable_pages(void *virt, int nr) /* Max number of entries allowed for each kvm dirty ring */ #define KVM_DIRTY_RING_MAX_ENTRIES 65536 +#endif /* __KVM__ */ + #endif diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index 6f4737d5046a..4804bce2a655 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h @@ -48,6 +48,8 @@ typedef u64 hfn_t; typedef hfn_t kvm_pfn_t; +#ifdef __KVM__ + enum pfn_cache_usage { KVM_GUEST_USES_PFN = BIT(0), KVM_HOST_USES_PFN = BIT(1), @@ -123,4 +125,5 @@ struct kvm_vcpu_stat_generic { #define KVM_STATS_NAME_SIZE 48 +#endif /* __KVM__ */ #endif /* __KVM_TYPES_H__ */ diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 3bd31ea23fee..aee85527bb74 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -2,8 +2,13 @@ #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_KVM_MAIN_H +#include #include +#ifndef __KVM__ +static_assert(0, "Do not include trace/events/kvm.h from non-KVM code"); +#endif + #undef TRACE_SYSTEM #define TRACE_SYSTEM kvm diff --git a/virt/kvm/Makefile.kvm b/virt/kvm/Makefile.kvm index e85079ad245d..4de10d447ef3 100644 --- a/virt/kvm/Makefile.kvm +++ b/virt/kvm/Makefile.kvm @@ -3,7 +3,7 @@ # Makefile for Kernel-based Virtual Machine module # -ccflags-y += -I$(srctree)/$(src) +ccflags-y += -I$(srctree)/$(src) -D__KVM__ KVM ?= ../../../virt/kvm