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 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 1021FCD13CF for ; Mon, 2 Sep 2024 18:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Cwl10KhhgV0xpkP0gByiPjTieYcFRCOsigTujs7ouOs=; b=33g5oij+jdJlONlPTbcxrabNJE alAIShYietBsjuGrf9ffOk83Zx8PLrQ6NQFU0A6FbK/hozL0YgOxZiMMsla0xHYzMIALOiPtM9Fam s1/oHvvu9Xagv3uoVDbbnPItxE47ZN9Tlx+1cyXkd0eQ+8SycZh4954ugjOKn6WWzIIi270YH8Zfw XWV/qMr9rJWBJx1eoTaaeQELVRH6hQz8aMUnhNxputC+/eYbscB/bpm3PFP785UJs1tEmrcUIe4dB ZkKiLgwU6pE2DRoq0mXKC+R8RCj/uTTOVIbpZ9uGp/s1tRs2nst4x8RQyLU1x7lFYj8fKsLPPGQda o3rp0RGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slCD7-0000000FKFj-1A1G; Mon, 02 Sep 2024 18:55:33 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slCCD-0000000FK1R-01v4; Mon, 02 Sep 2024 18:54:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD5495C58C2; Mon, 2 Sep 2024 18:54:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B088C4CEC2; Mon, 2 Sep 2024 18:54:27 +0000 (UTC) Date: Mon, 2 Sep 2024 19:54:25 +0100 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , Yury Khrustalev , Wilco Dijkstra , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v12 19/39] arm64/mm: Handle GCS data aborts Message-ID: References: <20240829-arm64-gcs-v12-0-42fec947436a@kernel.org> <20240829-arm64-gcs-v12-19-42fec947436a@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240829-arm64-gcs-v12-19-42fec947436a@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_115437_118654_60AC96A7 X-CRM114-Status: GOOD ( 17.49 ) 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 On Thu, Aug 29, 2024 at 12:27:35AM +0100, Mark Brown wrote: > All GCS operations at EL0 must happen on a page which is marked as > having UnprivGCS access, including read operations. If a GCS operation > attempts to access a page without this then it will generate a data > abort with the GCS bit set in ESR_EL1.ISS2. > > EL0 may validly generate such faults, for example due to copy on write > which will cause the GCS data to be stored in a read only page with no > GCS permissions until the actual copy happens. Since UnprivGCS allows > both reads and writes to the GCS (though only through GCS operations) we > need to ensure that the memory management subsystem handles GCS accesses > as writes at all times. Do this by adding FAULT_FLAG_WRITE to any GCS > page faults, adding handling to ensure that invalid cases are identfied > as such early so the memory management core does not think they will > succeed. The core cannot distinguish between VMAs which are generally > writeable and VMAs which are only writeable through GCS operations. > > EL1 may validly write to EL0 GCS for management purposes (eg, while > initialising with cap tokens). > > We also report any GCS faults in VMAs not marked as part of a GCS as > access violations, causing a fault to be delivered to userspace if it > attempts to do GCS operations outside a GCS. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown Reviewed-by: Catalin Marinas