From mboxrd@z Thu Jan 1 00:00:00 1970 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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 2062BC47089 for ; Wed, 26 May 2021 16:00:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC0FB613AC for ; Wed, 26 May 2021 16:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235370AbhEZQCB (ORCPT ); Wed, 26 May 2021 12:02:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:57690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234833AbhEZQCA (ORCPT ); Wed, 26 May 2021 12:02:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6003D613D3; Wed, 26 May 2021 16:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622044828; bh=GMrxEkqQtBsqG4xbv4zJPQYEf5zKU65KN8uhmCqvKnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vNOCNs4rdcNd40jifS0wBWkDQX8sn36ZWEkwjCN5CxhtYYhCTEOPxH4FU/g915two 6Utre0HKoDT2G8AgzkUTzZ/jAcpx/C1y6ORhCiVRmMkTjwW5Rs7GRs0FdecekzUJOy UW3rwkqMr2hjh8ScSvMLdfhLn4mjtvdIqVfPHKs8aqL0nqF6IaXWkzEZl2i7JU30fG DMtO/e4hS/KB8ckDUGW6yU8/y7mmrFVDa5qm5k446Wj4DQsSxU1qfKcj32xDHqV/TL YvDE+Vh2iOFGHfYkfd+V0tQMQVaDW6tQMSbQsAR5LXPiIfK75VN0bCH8xXfUfAn5jP zZx4IqUTCGp+A== Date: Wed, 26 May 2021 17:00:22 +0100 From: Will Deacon To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , 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 , kernel-team@android.com Subject: Re: [PATCH v7 22/22] Documentation: arm64: describe asymmetric 32-bit support Message-ID: <20210526160021.GA19691@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-23-will@kernel.org> <877djmwxbd.wl-maz@kernel.org> <20210525172703.GA17250@willie-the-truck> <875yz6wun3.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875yz6wun3.wl-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 07:11:44PM +0100, Marc Zyngier wrote: > On Tue, 25 May 2021 18:27:03 +0100, > Will Deacon wrote: > > > > On Tue, May 25, 2021 at 06:13:58PM +0100, Marc Zyngier wrote: > > > On Tue, 25 May 2021 16:14:32 +0100, > > > Will Deacon wrote: > > > > > > > > Document support for running 32-bit tasks on asymmetric 32-bit systems > > > > and its impact on the user ABI when enabled. > > > > > > > > Signed-off-by: Will Deacon > > > > --- > > > > .../admin-guide/kernel-parameters.txt | 3 + > > > > Documentation/arm64/asymmetric-32bit.rst | 154 ++++++++++++++++++ > > > > Documentation/arm64/index.rst | 1 + > > > > 3 files changed, 158 insertions(+) > > > > create mode 100644 Documentation/arm64/asymmetric-32bit.rst > > > > > > > > > > [...] > > > > > > > +KVM > > > > +--- > > > > + > > > > +Although KVM will not advertise 32-bit EL0 support to any vCPUs on an > > > > +asymmetric system, a broken guest at EL1 could still attempt to execute > > > > +32-bit code at EL0. In this case, an exit from a vCPU thread in 32-bit > > > > +mode will return to host userspace with an ``exit_reason`` of > > > > +``KVM_EXIT_FAIL_ENTRY``. > > > > > > Nit: there is a bit more to it. The vcpu will be left in a permanent > > > non-runnable state until KVM_ARM_VCPU_INIT is issued to reset the vcpu > > > into a saner state. > > > > Thanks, I'll add "and will remain non-runnable until re-initialised by a > > subsequent KVM_ARM_VCPU_INIT operation". > > Looks good. Cheers. > > Can the VMM tell that it needs to do that? I wonder if we should be > > setting 'hardware_entry_failure_reason' to distinguish this case. > > The VMM should be able to notice that something is amiss, as any > subsequent KVM_RUN calls will result in -ENOEXEC being returned, and > we document this as "the vcpu hasn't been initialized or the guest > tried to execute instructions from device memory (arm64)". > > However, there is another reason to get a "FAILED_ENTRY", and that if > we get an Illegal Exception Return exception when entering the > guest. That one should always be a KVM bug. > > So yeah, maybe there is some ground to populate that structure with > the appropriate nastygram (completely untested). > > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index 24223adae150..cf50051a9412 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -402,6 +402,10 @@ struct kvm_vcpu_events { > #define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS > #define KVM_PSCI_RET_DENIED PSCI_RET_DENIED > > +/* KVM_EXIT_FAIL_ENTRY reasons */ > +#define KVM_ARM64_FAILED_ENTRY_NO_AARCH32_ALLOWED 0xBADBAD32 > +#define KVM_ARM64_FAILED_ENTRY_INTERNAL_ERROR 0xE1215BAD Heh, you and your magic numbers ;) I'll leave it up to you as to whether you want to populate this -- I just spotted it and thought it might help to indicate what went wrong. This is a pretty daft situation to end up in so whether anybody would realistically try to recover from it is another question entirely. Will From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.9 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,USER_AGENT_SANE_1 autolearn=unavailable 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 1FFF7C47088 for ; Wed, 26 May 2021 17:10:46 +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 D6C8D611CD for ; Wed, 26 May 2021 17:10:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6C8D611CD 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0SnYvvAdS3x6fwFWw6K2veWGd6a39ewqGP2rikl3etc=; b=whLyQUSvToKARJ qX9UJd7E0CBu9mVq/9BIr8kQyeAFfMwO71B4VSInP9AxrMdiF3ky4yfdlIzANifq1ZLLh18t1nRfA l9OqrH4x/Tax4cW0S/bVlxqEXCtHMcUxHQKRDTbFbzjbc2zwXyRaQ71tr+jLRQXaNnr+RpDd9IpXd 4QQOGSzjfmJRSj0/LN4LA3ntwndhZ9BFv7QuxSl7tjpjeHpYmSiqMzx7NCAY0NbxDqxY117iDJnHE eNw9XRX4WlDU1Qqx5y0ZmJ8seeD/GTo+UuWnEZsgFSgw0NWZZXBtG1KZgagsuX/Ten5FovLTWJMqk GURYRk6QvSxECgt5YA6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llx1O-00FzNa-MG; Wed, 26 May 2021 17:08:43 +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 1llvxN-00FZWj-72 for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 16:00:30 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6003D613D3; Wed, 26 May 2021 16:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622044828; bh=GMrxEkqQtBsqG4xbv4zJPQYEf5zKU65KN8uhmCqvKnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vNOCNs4rdcNd40jifS0wBWkDQX8sn36ZWEkwjCN5CxhtYYhCTEOPxH4FU/g915two 6Utre0HKoDT2G8AgzkUTzZ/jAcpx/C1y6ORhCiVRmMkTjwW5Rs7GRs0FdecekzUJOy UW3rwkqMr2hjh8ScSvMLdfhLn4mjtvdIqVfPHKs8aqL0nqF6IaXWkzEZl2i7JU30fG DMtO/e4hS/KB8ckDUGW6yU8/y7mmrFVDa5qm5k446Wj4DQsSxU1qfKcj32xDHqV/TL YvDE+Vh2iOFGHfYkfd+V0tQMQVaDW6tQMSbQsAR5LXPiIfK75VN0bCH8xXfUfAn5jP zZx4IqUTCGp+A== Date: Wed, 26 May 2021 17:00:22 +0100 From: Will Deacon To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , 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 , kernel-team@android.com Subject: Re: [PATCH v7 22/22] Documentation: arm64: describe asymmetric 32-bit support Message-ID: <20210526160021.GA19691@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-23-will@kernel.org> <877djmwxbd.wl-maz@kernel.org> <20210525172703.GA17250@willie-the-truck> <875yz6wun3.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <875yz6wun3.wl-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210526_090029_379517_A914EC18 X-CRM114-Status: GOOD ( 34.11 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, May 25, 2021 at 07:11:44PM +0100, Marc Zyngier wrote: > On Tue, 25 May 2021 18:27:03 +0100, > Will Deacon wrote: > > > > On Tue, May 25, 2021 at 06:13:58PM +0100, Marc Zyngier wrote: > > > On Tue, 25 May 2021 16:14:32 +0100, > > > Will Deacon wrote: > > > > > > > > Document support for running 32-bit tasks on asymmetric 32-bit systems > > > > and its impact on the user ABI when enabled. > > > > > > > > Signed-off-by: Will Deacon > > > > --- > > > > .../admin-guide/kernel-parameters.txt | 3 + > > > > Documentation/arm64/asymmetric-32bit.rst | 154 ++++++++++++++++++ > > > > Documentation/arm64/index.rst | 1 + > > > > 3 files changed, 158 insertions(+) > > > > create mode 100644 Documentation/arm64/asymmetric-32bit.rst > > > > > > > > > > [...] > > > > > > > +KVM > > > > +--- > > > > + > > > > +Although KVM will not advertise 32-bit EL0 support to any vCPUs on an > > > > +asymmetric system, a broken guest at EL1 could still attempt to execute > > > > +32-bit code at EL0. In this case, an exit from a vCPU thread in 32-bit > > > > +mode will return to host userspace with an ``exit_reason`` of > > > > +``KVM_EXIT_FAIL_ENTRY``. > > > > > > Nit: there is a bit more to it. The vcpu will be left in a permanent > > > non-runnable state until KVM_ARM_VCPU_INIT is issued to reset the vcpu > > > into a saner state. > > > > Thanks, I'll add "and will remain non-runnable until re-initialised by a > > subsequent KVM_ARM_VCPU_INIT operation". > > Looks good. Cheers. > > Can the VMM tell that it needs to do that? I wonder if we should be > > setting 'hardware_entry_failure_reason' to distinguish this case. > > The VMM should be able to notice that something is amiss, as any > subsequent KVM_RUN calls will result in -ENOEXEC being returned, and > we document this as "the vcpu hasn't been initialized or the guest > tried to execute instructions from device memory (arm64)". > > However, there is another reason to get a "FAILED_ENTRY", and that if > we get an Illegal Exception Return exception when entering the > guest. That one should always be a KVM bug. > > So yeah, maybe there is some ground to populate that structure with > the appropriate nastygram (completely untested). > > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index 24223adae150..cf50051a9412 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -402,6 +402,10 @@ struct kvm_vcpu_events { > #define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS > #define KVM_PSCI_RET_DENIED PSCI_RET_DENIED > > +/* KVM_EXIT_FAIL_ENTRY reasons */ > +#define KVM_ARM64_FAILED_ENTRY_NO_AARCH32_ALLOWED 0xBADBAD32 > +#define KVM_ARM64_FAILED_ENTRY_INTERNAL_ERROR 0xE1215BAD Heh, you and your magic numbers ;) I'll leave it up to you as to whether you want to populate this -- I just spotted it and thought it might help to indicate what went wrong. This is a pretty daft situation to end up in so whether anybody would realistically try to recover from it is another question entirely. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel