From patchwork Tue Jun 8 18:02:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12307835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22891C4743D for ; Tue, 8 Jun 2021 18:07:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E984761377 for ; Tue, 8 Jun 2021 18:07:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E984761377 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:References:In-Reply-To: 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: List-Owner; bh=Owwbx9yudzyGL8Yxg+NV4tRja/x7FE1uieXSeJvgo5E=; b=P5ZmJbRWb8dth8 GWVAC3hRGnDuxHLfARY3Ex3AEfSdKTVywFG3VdHBAdTEzNYbsNaiipVq3tZtyt1sZauZ4xz5cKT/Z vL0fq19Y0GgFqHjg7EEAdzhUWIlXG+BTND3425wauUf5gakA2d7i5miGQreSG5qt3Fedtj+e1wcrD 8HnCShAcz/OSJJ3Nox18VoHteg4cwowFmSZtbc9MxeqCuwvV4kf7jQ6UlKGrQjLfODhFNeOLa7e8f 2YrOw6MVYN6mFxZtF2VeoNn5OBK73waQIJTn4CBI5zYKVIFQ3tR+75qUPgh9iBWSu6kDpX3c5NIIi Ngmflzq4YYWNDnFnTzyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqg5Y-009r8M-GO; Tue, 08 Jun 2021 18:04:33 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqg4h-009qjQ-HW for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 18:03:40 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D68061376; Tue, 8 Jun 2021 18:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623175419; bh=1lja7ipnOASJEry7DBAucjsSqRdJUTw7D05wcU0XEhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dpskNZRYRJUTGfzqtk27ThTc0rw49rfv1jb7+u0XIzZHsdlA7mFXjHIEnzBJy/zMU jqPTmxMjcboiTK98XjFV/Xy63zr2l3vl6Rv2LicF+G5UY3TunlC5YUWFxqxdU4teef d+GsBL8fqY9KNSh8XAF9ASdJ+8NKXN52wDFR+CORtIaQ5LkSTUKrrj1GUO3cNP3HDS ZBIGyB09mumD8GDYaPpnAYh5g7EmLckUrhSkrfFetbQFmqXh+bsjHx2QyYs20gCY26 BfFMas7+yATDkcZFw/OLKD/1XVCancE+V2eAzID7WfBj5xqEUyMXWPnru0XkkK0URM 3skKgesNJ/CNg== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , Dietmar Eggemann , Daniel Bristot de Oliveira , Valentin Schneider , Mark Rutland , kernel-team@android.com Subject: [PATCH v9 03/20] KVM: arm64: Kill 32-bit vCPUs on systems with mismatched EL0 support Date: Tue, 8 Jun 2021 19:02:56 +0100 Message-Id: <20210608180313.11502-4-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210608180313.11502-1-will@kernel.org> References: <20210608180313.11502-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_110339_625355_F2A351CC X-CRM114-Status: GOOD ( 13.07 ) 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 a vCPU is caught running 32-bit code on a system with mismatched support at EL0, then we should kill it. Acked-by: Marc Zyngier Reviewed-by: Catalin Marinas Signed-off-by: Will Deacon --- arch/arm64/kvm/arm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 1cb39c0803a4..5bdba97a7654 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -692,6 +692,15 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu) } } +static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu) +{ + if (likely(!vcpu_mode_is_32bit(vcpu))) + return false; + + return !system_supports_32bit_el0() || + static_branch_unlikely(&arm64_mismatched_32bit_el0); +} + /** * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code * @vcpu: The VCPU pointer @@ -875,7 +884,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) * with the asymmetric AArch32 case), return to userspace with * a fatal error. */ - if (!system_supports_32bit_el0() && vcpu_mode_is_32bit(vcpu)) { + if (vcpu_mode_is_bad_32bit(vcpu)) { /* * As we have caught the guest red-handed, decide that * it isn't fit for purpose anymore by making the vcpu