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.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 4CAF5C63697 for ; Thu, 26 Nov 2020 18:45:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 C6E9C21D1A for ; Thu, 26 Nov 2020 18:45:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iGcSmeUW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6E9C21D1A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mL8D8Bf6s0nVFDkSiVoni81Q08jw4h8ZG/Almz0Wdy8=; b=iGcSmeUWSJaUb01Y9UumsUYm+ JtcVlyM1w3eM76ZjpTNePmdJt9hMIAfmVE6haO3mN5dD67g5SVwL1dGVAz1uwlIcxmb/TlnLI6c4t Gmw7XLJootv67uhPpV1jFfRbj8PRu/r09aX63qX78jMzmxMk/hgEI5YzFqLB2/qAOyusjelYQDQF6 GjChhT16bubJYyXslxcr2GNKJbu8eORN1UN+BJYZslmpKO91y5+kdMZD7nmH8rTAIRhxroKKQkb5x jXYiX9G2vVQHCghfmxMMqJqlE0f5StrJLCIYlfNLU834LH8t1lqqWCkCp+XmjiQJ8DFNMfmG/idCL JEleMJFfQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiMFF-0004dP-KO; Thu, 26 Nov 2020 18:43:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiMEE-0004Io-3M for linux-arm-kernel@lists.infradead.org; Thu, 26 Nov 2020 18:42:51 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 993B516F8; Thu, 26 Nov 2020 10:42:49 -0800 (PST) Received: from [172.16.1.114] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 23E9E3F23F; Thu, 26 Nov 2020 10:42:47 -0800 (PST) Subject: Re: [PATCHv4 07/17] arm64: sdei: explicitly simulate PAN/UAO entry To: Mark Rutland , linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org References: <20201113124937.20574-1-mark.rutland@arm.com> <20201113124937.20574-8-mark.rutland@arm.com> From: James Morse Message-ID: Date: Thu, 26 Nov 2020 18:42:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201113124937.20574-8-mark.rutland@arm.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201126_134250_346872_DBFCC2CF X-CRM114-Status: GOOD ( 21.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robin.murphy@arm.com, hch@lst.de 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 Hi Mark, On 13/11/2020 12:49, Mark Rutland wrote: > SDEI enters the kernel with a non-architectural exception which does not > manipulate PSTATE bits (e.g. PAN, UAO) in the same way as architectural > exceptions. We currently fix this up with a combination of > __uaccess_enable_hw_pan() and force_uaccess_access_begin(), but this has > a few problems: > > * When set_fs() is removed, force_uaccess_begin() will have no HW > side-effects, and UAO will need to be reset elsewhere. > > * Kernels built without support for PAN or UAO will not reset these bits > upon SDEI entry, and may inherit the values used by a VM, leading to > unexpected behaviour. > > * Kernels built *with* support for PAN or UAO, when run on systems with > mismatched support across CPUs, will not reset these bits upon SDEI > entry, and may inherit the values used by a VM, leading to unexpected > behaviour. > To deal with all of these, let's always explicitly reset the PAN and UAO > bits when an SDEI event is delivered to the kernel. As above, we must do > so even when the kernel has chosen to not use PAN/UAO, or was not built > with support for PAN/UAO generally. > > The existing system_uses_ttbr0_pan() is redefined in terms of > system_uses_hw_pan() both for clarity and as a minor optimization when > HW PAN is not selected. Reviewed-by: James Morse > diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c > index 4a5f24602aa0..908d7be70eac 100644 > --- a/arch/arm64/kernel/sdei.c > +++ b/arch/arm64/kernel/sdei.c > @@ -224,12 +234,11 @@ __sdei_handler(struct pt_regs *regs, struct sdei_registered_event *arg) > mm_segment_t orig_addr_limit; > > /* > - * We didn't take an exception to get here, so the HW hasn't set PAN or > - * cleared UAO, and the exception entry code hasn't reset addr_limit. > - * Set PAN, then use force_uaccess_begin() to clear UAO and reset > - * addr_limit. > + * We didn't take an exception to get here, so the HW hasn't > + * set/cleared bits in PSTATE that we may rely on. Intialize PAN/UAO, (Initialize) > + * then use force_uaccess_begin() to reset addr_limit. > */ > - __uaccess_enable_hw_pan(); > + __sdei_pstate_entry(); > orig_addr_limit = force_uaccess_begin(); > > nmi_enter(); > Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel