From nobody Sat Nov 15 05:39:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1755087050029754.0449503833689; Wed, 13 Aug 2025 05:10:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1umAIU-0001Wp-4o; Wed, 13 Aug 2025 08:09:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1um54G-0007mS-13 for qemu-devel@nongnu.org; Wed, 13 Aug 2025 02:34:36 -0400 Received: from mail-a.sr.ht ([46.23.81.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1um547-0007sK-VD for qemu-devel@nongnu.org; Wed, 13 Aug 2025 02:34:34 -0400 Received: from git.sr.ht (unknown [46.23.81.155]) by mail-a.sr.ht (Postfix) with ESMTPSA id AC34C22F05; Wed, 13 Aug 2025 06:34:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xxKj4TOvFOZFX6/ej7ZAYlJchHepX4BzMPjaosHHXYA=; c=simple/simple; d=git.sr.ht; h=From:Date:Subject:Reply-to:In-Reply-To:To:Cc; q=dns/txt; s=20240113; t=1755066860; v=1; b=pF9xoB8++h+GL+9IXZ3dWx7BMkdtvzOuCBwlZrMQs582bgCYbyX4Ybb1ccqzAH0AQItWWSF7 SdcmSKh++TN9evSA1uSm0KPKZkLXWA6emqDemxbm/LnFr2+90VwTIpcjeAvJx2qFyMX+QL1UQGK JduOJkMKR2re9b2V8CfV5XJOuYjBZXxjprQJW0Yq274aljiJK63agzTHSEKTQZ7dFNP2H1EoGyF 0OCXGVjO3C+96K938bL6kH4bqfrPiOHAwT7Qu9SixzaOY4Pw4QEbYALCoZ/GaFr09An83hCJ6Si yKOfQqYRRvmcQaqs+pBLTC2a+kvsZmKS4C2Vj3YXjM5qw== From: ~myrslint Date: Wed, 13 Aug 2025 06:23:24 +0000 Subject: [PATCH qemu 1/1] Default disable ignore guest PAT quirk Message-ID: <175506686028.15648.7602021948044277748-1@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <175506686028.15648.7602021948044277748-0@git.sr.ht> To: qemu-devel@nongnu.org Cc: Paolo Bonzini Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=46.23.81.152; envelope-from=outgoing@sr.ht; helo=mail-a.sr.ht X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 13 Aug 2025 08:09:32 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~myrslint Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1755087054397124100 From: myrslint Addresses this issue: https://gitlab.com/qemu-project/qemu/-/issues/2943 Most Intel CPUs in current use have self-snoop. The few added lines of code also check for availability of the quirk disablement option so if some CPU does not have this feature no change of behavior will occur. --- accel/kvm/kvm-all.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 890d5ea9f8..c3d06ae2f8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2682,6 +2682,32 @@ static int kvm_init(AccelState *as, MachineState *ms) =20 s->vmfd =3D ret; =20 +/* if target platform has no notion of this or kernel version does + * not have it there is no use for compiling this in */ +#ifdef KVM_X86_QUIRK_IGNORE_GUEST_PAT + /* first check for modifiable quirks bitmask */ + ret =3D kvm_check_extension(s, KVM_CAP_DISABLE_QUIRKS2); + /* next make sure disabling it is allowed */ + if (ret & KVM_X86_QUIRK_IGNORE_GUEST_PAT) { + struct kvm_enable_cap *cap; + cap =3D calloc(1, sizeof(struct kvm_enable_cap)); + if (cap) { + cap->cap =3D KVM_CAP_DISABLE_QUIRKS2; + cap->args[0] =3D KVM_X86_QUIRK_IGNORE_GUEST_PAT; + /* if intel cpu does not support self-snoop this is a nop */ + ret =3D kvm_vm_ioctl(s, KVM_ENABLE_CAP, cap); + if (ret < 0) { + error_printf("KVM_X86_QUIRK_IGNORE_GUEST_PAT available and= " + "modifiable but we failed to disable it\n"); + } + free(cap); + } else { + error_printf("KVM_X86_QUIRK_IGNORE_GUEST_PAT: could not " + "allocate memory\n"); + } + } +#endif + s->nr_as =3D kvm_vm_check_extension(s, KVM_CAP_MULTI_ADDRESS_SPACE); if (s->nr_as <=3D 1) { s->nr_as =3D 1; --=20 2.49.1