From patchwork Fri Sep 2 04:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 12963621 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 DE8B0ECAAA1 for ; Fri, 2 Sep 2022 04:03:26 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aWPWOV5KzUKpHbnRShQPyDFsmXbYiEOF2uFCzNgQswg=; b=mBnQ7wmPDp2BOj Z96dZB9ixtNS9ocHheyuA5uZX9X5VGt2U37DgWn1VvTDUZQfbQ666AlBqLHtrmxlXG8WrMRyfy4SL p/mZt4qI3hwQl/gPuaZAvRU6uzFyjTk18qBiGs4q3zunnXR4OJ92KmCWmOP0IIOXR/LufGXWK4sjJ n+2xSTp567fNxxvc9itpAfIrIanC6XPcja3JUOtDUK68AiyHnUYlFlNvq0MzZaNSQ9mErzGcHchy0 4oVAgdy8ZPa54FkqWrzWs4tjqmcivHQmsk5gPoxvXYUu3FsICbrpbhgJ7JkALTW4IrZHdbycg2YDV gOpJHSaSCNk7MEJn4nBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTxsb-00HaJ6-5y; Fri, 02 Sep 2022 04:02:05 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTxsY-00HaGS-7d for linux-arm-kernel@lists.infradead.org; Fri, 02 Sep 2022 04:02:03 +0000 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2822hkR8025773; Fri, 2 Sep 2022 04:01:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=RwLiYzXm6r2X0x4XwkSBRoKpf6qf5vVIv6Dkj9YDXz8=; b=ADmkc5QA35z3i+QHOLEdEuRAR6SbmQ+jJBSdp5ewmMZ+NU2lrgSFtRLHLC9Li+68PYG2 QNJbQ6xG5+xs6Wls/FxF1ARIXcFriscoWO6tnsJyO8xssjRMtjI+sVSnnsM9hl/83yPW 8vdWXMB93KFxsYDn94LN8acqlkjUxfbUJmFIM+qafFM8joLPYUvS0JxhSTTzB1EkslWL rMf50173+/MttVBUOq3lljA8hVuGHDZMM2NhF2p3EKh5oF7AxIkv/MfV+vEjydjW+n2G VUZkaoqNektl9nK34PVkcNRKyaH152dS6kKHBk6esf3lYBSJfMB6b1xB1v4Y4e+K+PPx 8g== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jarc83emg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Sep 2022 04:01:48 +0000 Received: from nasanex01b.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 28241lU6011351 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 2 Sep 2022 04:01:47 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 1 Sep 2022 21:01:47 -0700 From: Elliot Berman To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , "Alexandru Elisei" , Suzuki K Poulose CC: Elliot Berman , , , , David Brazdil Subject: [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled Date: Thu, 1 Sep 2022 21:01:22 -0700 Message-ID: <20220902040122.346654-1-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: DfMzIoHNv196IU4pP0vUlh7u1aZbRIJQ X-Proofpoint-GUID: DfMzIoHNv196IU4pP0vUlh7u1aZbRIJQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-09-01_12,2022-08-31_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1011 priorityscore=1501 spamscore=0 mlxscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209020018 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220901_210202_431021_5F5AB96D X-CRM114-Status: GOOD ( 19.26 ) 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 If "kvm-arm.mode=protected" is present on kernel command line, but the kernel doesn't actually support KVM because it booted from EL1, the ARM64_KVM_PROTECTED_MODE capability is misleadingly reported as present. Fix this by adding a check whether we booted from EL2. Cc: Will Deacon Cc: David Brazdil Cc: Marc Zyngier Signed-off-by: Elliot Berman --- arch/arm64/kernel/cpufeature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8d88433de81d..866667be0651 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1974,7 +1974,7 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) #ifdef CONFIG_KVM static bool is_kvm_protected_mode(const struct arm64_cpu_capabilities *entry, int __unused) { - return kvm_get_mode() == KVM_MODE_PROTECTED; + return is_hyp_mode_available() && kvm_get_mode() == KVM_MODE_PROTECTED; } #endif /* CONFIG_KVM */