From patchwork Mon Jan 10 03:47:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Like Xu X-Patchwork-Id: 12708151 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03135C433EF for ; Mon, 10 Jan 2022 03:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238396AbiAJDr6 (ORCPT ); Sun, 9 Jan 2022 22:47:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235727AbiAJDr5 (ORCPT ); Sun, 9 Jan 2022 22:47:57 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57F3C06173F; Sun, 9 Jan 2022 19:47:57 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id 78so1527384pfu.10; Sun, 09 Jan 2022 19:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pbRI1T2l3Qets8v52jJPGd5CiuQtZXN6jFwWiPsneXQ=; b=ZQrHf3jO6LZaTeDXee6HHvFaG63VScf3A579kXtpX+vWMW89xqhJtHSavilLKTZl51 NzGWoTpFw5kZpbBh53spzudlfCV5cxMfKWnNNRQlvfFc4Kj6/OKQw5ugyo1Afdkzy5Xs RDIlmpoyadyfpqnzFuOuzsaaB2sopn2/+UGWQikvhGiNQfdS5NqcOWVfQ4n79biFp1wo 18ibrr7YMTqPIiqHPoaTatCKvDUod8BXRae4PZfEm6hC2sgGmy6+fawymfsfSd1ks4ko bXwRUeGq3aBWmTh5591jivivDCbvOY0de1atWIYOPRQQg7C7vJRb4qztSrR5R+XPsQjj CTqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pbRI1T2l3Qets8v52jJPGd5CiuQtZXN6jFwWiPsneXQ=; b=TJolqRozm+vEyWc8rP4X8n+yEJZPPdatMLYzZOEMJVBDhD89vMzIPzrqL65WReA6Sh hddae0TYh9ec6xCZLt54W9hIwTDnOHgvkYYJFAegxKmGsoM5fX82KdrV4nkSkkp6NzBp QmkIUgZUdha7q2jNs3QO1XJSPisrLhn3gMf/ZSgxZWkPjrKs6i1hJLoBowPgnKElQPvF GrJ+knzj1xTjdBi3NiAAn+B53tgGbyuIdvWLptZmr2H4GkW8H3Oi3pojv36+fYy1snR6 xGovqF+kQ8bdtpeLsfAK76GRqbeUIJF8DcsSswd6wsd4/0ZRzRdR33Av1jCvSz3HJsDt 886w== X-Gm-Message-State: AOAM531wJquWcRURme4da9Bnub8EZtmQiweJSdoQE55srHFIA2Or7TQQ Y2jy+oyD/9NtBhACf2f7B8E= X-Google-Smtp-Source: ABdhPJzl1NMgZcIY8d5zzP0k4fAzrUgdzf8ewwbTJFYPcTSl9+pX/TDHiD3BnvEAZyn4BqAB+i0FbQ== X-Received: by 2002:a63:2056:: with SMTP id r22mr63042594pgm.460.1641786477305; Sun, 09 Jan 2022 19:47:57 -0800 (PST) Received: from localhost.localdomain ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id s5sm4607660pfe.117.2022.01.09.19.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:47:56 -0800 (PST) From: Like Xu X-Google-Original-From: Like Xu To: Paolo Bonzini Cc: Sean Christopherson , Jim Mattson , Wanpeng Li , Vitaly Kuznetsov , Joerg Roedel , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] KVM: x86/pt: Ignore all unknown Intel PT capabilities Date: Mon, 10 Jan 2022 11:47:47 +0800 Message-Id: <20220110034747.30498-1-likexu@tencent.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Like Xu Some of the new Intel PT capabilities (e.g. SDM Vol3, 32.2.4 Event Tracing, it exposes details about the asynchronous events, when they are generated, and when their corresponding software event handler completes execution) cannot be safely and fully emulated by the KVM, especially emulating the simultaneous writing of guest PT packets generated by the KVM to the guest PT buffer. For KVM, it's better to advertise currently supported features based on the "static struct pt_cap_desc" implemented in the host PT driver and ignore _all_ unknown features before they have been investigated one by one and supported in a safe manner, leaving the rest as system-wide-only tracing capabilities. Suggested-by: Paolo Bonzini Signed-off-by: Like Xu --- v1 -> v2 Changelog: - Be safe and ignore _all_ unknown capabilities. (Paolo) Previous: https://lore.kernel.org/kvm/20220106085533.84356-1-likexu@tencent.com/ arch/x86/kvm/cpuid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 0b920e12bb6d..439b93359848 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -901,6 +901,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) break; } + /* It's better to be safe and ignore _all_ unknown capabilities. */ + entry->ebx &= GENMASK(5, 0); for (i = 1, max_idx = entry->eax; i <= max_idx; ++i) { if (!do_host_cpuid(array, function, i)) goto out;