From patchwork Mon Feb 14 06:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12745046 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 729CBC4332F for ; Mon, 14 Feb 2022 07:04:24 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lkTQZ8dNhOPDSUF1DL91iFeRW1Gyeu+cwWMT+rB/qag=; b=rl2vjFo8ABJqhjGiga1A+AOlPr z9HOtF0tAcbJhmOcmukw9nhGWKkslbbiT+mLwNk7Uwtg80qTE8L6sCYKyLwK7mR3fg9CDNydZAqxu O6PiQpqZe9wCXXyr4NXEEz7N7i1NBPCGzN9KMTfs9LbVT15TKvrkvw+mCpYn1lE+lGPhmRM6oBk55 jMSSg0e28WS2PV0SGV9vmzR+6/zxY2dX6efL/WX5UNi24OHMw9WUQ4pNtJMJVAnklSG15V4ymCG1C PDj5jN77rK/XPYbN+N0o6QmvUc7TLKeHcs26eoRPApU7RwO8GGmOQDeNnmbp077bGZjUbxg/SBw9m hCQYS9yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJVNt-00DYAb-PY; Mon, 14 Feb 2022 07:02:53 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJVL3-00DWjR-6G for linux-arm-kernel@lists.infradead.org; Mon, 14 Feb 2022 06:59:59 +0000 Received: by mail-pj1-x104a.google.com with SMTP id y10-20020a17090a134a00b001b8b7e5983bso10291216pjf.6 for ; Sun, 13 Feb 2022 22:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=03TUyFaPg0/Gjl+vQfTSvgoxQ+5uxs9Hi6MR9A6wLJ8=; b=KcLvYfrEmbcbn9/knN5ogFzworOFEeVL5ZK8AZWWTFU0yGrQ6hL5mDfGOL7otoY7DR MyXrJDy49UxK0NIylHzK5Kb2vY5ZA3xGz37wsQNkJTS8gxji/7yEkk7ZAj6jvZCtspx8 MdP3LyyAIa4guOEcXFwmjfL55hNOw3+XlP66BJuic56ao47fmmNw8vZtsWUpmU0kdsAz QiuI4vQKwMgyMdez4e0eoBFAWk5ZE58xz9J0/ZqFIYYdwrRbzcYtVJDPR5cHipUfImVa 1KH0lY3Hlg2gzWwhjWzN3a1U1mJ/R4Am9ZBJ6ItMl/BtBeQ6A5e//6G8Y//FT3r6R1AF 259A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=03TUyFaPg0/Gjl+vQfTSvgoxQ+5uxs9Hi6MR9A6wLJ8=; b=6fa+nokLFvu6c2CzKexfzNdtm/4m5EDdYD8Pcd99O8LdZdR1TJVr92+p6DE0eobzX/ GBN5fKvMNxtCT97IyJ/46GuHlVR3oMhL4TPSBpeRE58O4ABG1SlE2YAu0mrlxU8oMnK2 ZWAXKxffDgtYQX6jdFfNT3zDJLaHypdgpMKGszUi0sn82TOz4yYdCfuFmV6lNbCDnHv5 lKt9rtXkIWamy4hs1V86FxS3ZBYbK1GsVo2NKDB5YkBfpH4FFUHvz2rat3kV9p5gMBUF jnX+1kDdUTR6gvKPXlrEWOrlUqcQYYolPFy4r+A8h238jF0LZEGtM46hOZ8w5JvYkeOQ MTvw== X-Gm-Message-State: AOAM530Ik7OceMAiQwedwniGI1SzVULHWzwsH+HjWOK6/cQCIYLvBVRM mTvMY43z1ll+aRdzCT6BKPSWO8seZtM= X-Google-Smtp-Source: ABdhPJy+Udb+Z+ZE+Rw3PccqevtrcStNlD43OiYvy5Bfz0Nf6G3t2aLz7nIFNg+rtbp1DbKZPXtNfE5VWfk= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a17:903:2441:: with SMTP id l1mr12577060pls.142.1644821995705; Sun, 13 Feb 2022 22:59:55 -0800 (PST) Date: Sun, 13 Feb 2022 22:57:29 -0800 In-Reply-To: <20220214065746.1230608-1-reijiw@google.com> Message-Id: <20220214065746.1230608-11-reijiw@google.com> Mime-Version: 1.0 References: <20220214065746.1230608-1-reijiw@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH v5 10/27] KVM: arm64: Hide IMPLEMENTATION DEFINED PMU support for the guest From: Reiji Watanabe To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Will Deacon , Andrew Jones , Fuad Tabba , Peng Liang , Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220213_225957_320097_2A8561FD X-CRM114-Status: GOOD ( 12.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When ID_AA64DFR0_EL1.PMUVER or ID_DFR0_EL1.PERFMON is 0xf, which means IMPLEMENTATION DEFINED PMU supported, KVM unconditionally expose the value for the guest as it is. Since KVM doesn't support IMPLEMENTATION DEFINED PMU for the guest, in that case KVM should expose 0x0 (PMU is not implemented) instead. Change cpuid_feature_cap_perfmon_field() to update the field value to 0x0 when it is 0xf. Fixes: 8e35aa642ee4 ("arm64: cpufeature: Extract capped perfmon fields") Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index a9edf1ca7dcb..375c9cd0123c 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -553,7 +553,7 @@ cpuid_feature_cap_perfmon_field(u64 features, int field, u64 cap) /* Treat IMPLEMENTATION DEFINED functionality as unimplemented */ if (val == ID_AA64DFR0_PMUVER_IMP_DEF) - val = 0; + return (features & ~mask); if (val > cap) { features &= ~mask;