From patchwork Sat Mar 1 07:34:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13997392 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BB261C5F29 for ; Sat, 1 Mar 2025 07:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740814481; cv=none; b=SV7L/Sb7S2BLp+R9moGziOu9qMWKekHszc4jON7PiaXVKRWn7Cijdk2ZWs5PG669yRpihNvlNh80htLa72pYvdwx8Bln53hvvIQF60bvOEN9fNiDU8f/3TSWRRyylX4v5BkRqy3R382z3EV7hRh4Dqz1vUH92WChLfs9zD8aEhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740814481; c=relaxed/simple; bh=mjCjCQrwYLhoQygEZbO+xcpp25yMQVFQETUKQNmSPxs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=lHyKdMvMzhVWGflfsjR8oAX7yrGw71LyjKDNJrQfpu4KAGGoLePFLQAI0ymzZZTZYsnySWYRtRNcaZUVDs2hZoWtsrKewx4/D3aCeUN/Ey6BzLiNE2T3pxNNdWmkyp88A8OCMubRX5B+8MZWDwclL0v4XKlEPXQeMt48UzWeNBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CJnHhFK+; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CJnHhFK+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740814477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oTew7YIDkUBPd0YXoSOPrIXt1zAfiwc8cYB60U7byAE=; b=CJnHhFK+sbpRRAt6vH1zBmSP5n1CM7qiNpGZ+yVZdgylqCEj+cX/ExzlCzz4MLlS+I9u0T gP4oDxkKqFWqkQopvT9FhxWT8QkNB9OMHyhHn0drN2cXeAYOGv2o5Dz57Z0mLGvh3/RqDv zD3zA3JDAUs/b0AQMuQ9MZITgcDWUsE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-9mKELwj5M6Of-jjui05R2w-1; Sat, 01 Mar 2025 02:34:31 -0500 X-MC-Unique: 9mKELwj5M6Of-jjui05R2w-1 X-Mimecast-MFC-AGG-ID: 9mKELwj5M6Of-jjui05R2w_1740814470 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6390D1954B20; Sat, 1 Mar 2025 07:34:30 +0000 (UTC) Received: from virtlab1023.lab.eng.rdu2.redhat.com (virtlab1023.lab.eng.rdu2.redhat.com [10.8.1.187]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A7B4119560AE; Sat, 1 Mar 2025 07:34:29 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, yan.y.zhao@intel.com Subject: [PATCH v2 0/4] KVM: x86: Introduce quirk KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT Date: Sat, 1 Mar 2025 02:34:24 -0500 Message-ID: <20250301073428.2435768-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 This series is my evolution of Yan's patches at https://patchew.org/linux/20250224070716.31360-1-yan.y.zhao@intel.com/. The implementation of the quirk is unchanged, but the concepts in kvm_caps are a bit different. In particular: - if a quirk is not applicable to some hardware, it is still included in KVM_CAP_DISABLE_QUIRKS2. This way userspace knows that KVM is *aware* of a particular issue - even if disabling it has no effect because the quirk is not a problem on a specific hardware, userspace may want to know that it can rely on the problematic behavior not being present. Therefore, KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT is simply auto-disabled on TDX machines. - if instead a quirk cannot be disabled due to limitations, for example KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT if self-snoop is not present on the CPU, the quirk is removed completely from kvm_caps.supported_quirks and therefore from KVM_CAP_DISABLE_QUIRKS2. This series does not introduce a way to query always-disabled quirks, which could be for example KVM_CAP_DISABLED_QUIRKS. This could be added if we wanted for example to get rid of hypercall patching; it's a trivial addition. Paolo Bonzini (1): KVM: x86: Allow vendor code to disable quirks Yan Zhao (3): KVM: x86: Introduce supported_quirks to block disabling quirks KVM: x86: Introduce Intel specific quirk KVM_X86_QUIRK_EPT_IGNORE_GUEST_PAT KVM: TDX: Always honor guest PAT on TDX enabled platforms Documentation/virt/kvm/api.rst | 22 ++++++++++++++++++ arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/mmu.h | 2 +- arch/x86/kvm/mmu/mmu.c | 11 +++++---- arch/x86/kvm/svm/svm.c | 1 + arch/x86/kvm/vmx/tdx.c | 6 +++++ arch/x86/kvm/vmx/vmx.c | 40 +++++++++++++++++++++++++++------ arch/x86/kvm/x86.c | 10 +++++---- arch/x86/kvm/x86.h | 14 +++++++----- 9 files changed, 86 insertions(+), 21 deletions(-)