From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB86045040D for ; Thu, 20 Aug 2026 13:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787232460; cv=none; b=PIEiUpSZ53WmjD9+QMLKnvHXMIZnQrV6tz/6NNfYe0JOusm9Z1Qystn63m1gSI96hXLvvVWEknXSM938+fAWrz1b1INyV0YoS4NUor6Z096//FRkFXvAhIGpqSSmznvJIRo0zQKK7vdEP3pQuK04KTNEyICq3ITxRrYpY3PSD0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787232460; c=relaxed/simple; bh=+SdpdDD75Et7iUr1bfUimSJDvhfY48HkhbWpzMccHZ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VTDgijGe7o5f4T9sepnp7DEPHd4mvuRvxHvN1rRtDCyme7V1f19M8vrFZm73Ts61NJRcBh+buH8jRkwA1nB1b/38cp0LDOmZSuYf6UtkRKRrehSgExs6yu0XdL90gKcJBxhjVeUrOuiNxXfWGGMN30C1O+Jg9MTnQRDLg+3skw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=f5GGMeQ6; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="f5GGMeQ6" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-51c2a76536bso21669101cf.1 for ; Thu, 20 Aug 2026 06:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1787232458; x=1787837258; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+OWRyp1Na2XBrlQ7bIW9EaBkPnu+lSJuThzM8dmXiRw=; b=f5GGMeQ62l1qkeXq0IDhBhJgcn5l+frZ35Q3CjQmPdj5sUz3TdruisNDQCXkCC61ot At/xY5Z6JRnB/c1g1qU+jM4Cf+4bWnWW7MsvGeChpfJ1uCiRzFsEvSPJJk/CdnkRzZhh c7FkqN2bc2UbEgCzNgEeoPjoJpRpq56WUb1kmygjvwbs94lgK9A1oJL2Df2zBFPtjd0l K+x7xZnBPrgt7iupSlpJhasqk7hXlEMzpxjiHqAOP4IisHzurcBJJ5uI6v4hmZj4NxXF y1Ioi1PNDnaQsYz2FHQJV2NuQJglcVG0EHM64zQnOF1E5BbagQYLqcqiapAo+ceggm5s 0VSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787232458; x=1787837258; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+OWRyp1Na2XBrlQ7bIW9EaBkPnu+lSJuThzM8dmXiRw=; b=aNwa4bmj68SXbArWNyMsHnTvBmMiSDOo4gaezPvj6uW5uaYmdtlqEq5e/145qyVLwx YkMxWzaoS7tS+PW/QYCxoMq2YnRJqJ2YEoOCrqGJuSWTwUgjegyotpHa4RMo6OGI0XJM tkxSoVohPtGG9P8chghKJ6pjNvcHoLC6dGVqx8zygsxAC0r5JwfZU1zsvzntC8b+VX8d 1YiqLC5XvwTzjZN8Hyj99a/LubEDpaooeYHAINaL83u3yoEhCH8+zG/ack1eNl/9PQxA 26mHNVlNqPeoahSKF0NTk5MkQPn0eHqRem1MwAY0FAf4N+93b/mixEWlHe0Bm4iOlGBr j+5A== X-Forwarded-Encrypted: i=1; AHgh+RrpPGUjH+WFT6XzB8gPEU1x6ZTule8zuNKAeWZZ6H7JV9oyHPp/MScTdNxAiqKQOkG3dyz6wLhHPx6XK0E=@vger.kernel.org X-Gm-Message-State: AOJu0YxqH+wXhV6TUY/J/nMMRSQXNDxj4URlIW7KF7Sad+HLSmxJ3IYw cbeRUV32Bn2EMJZBQvH7TG1jlF0PL7Hz0r2x5XOPZ6AO1xgw/0THb4Ae/zocg0BJCPk= X-Gm-Gg: AR+sD128+DbeQBf/2q06D0vpGr811d/zhREN4rZFHAJxCCV1jkoVST06zE5a0pVW1f4 FCYAiF5560TVpBGgykd07jNdIEF1Zmm+nmym//BfJ5jxiRf53g9kXuYwO7Rjh+5Cfgb1d9IY0kp 0yTVJOq23Fc99quYDHbuLMrGcxfcU8Sir+O4g5MHxwP0d4mNUhqVDyfMqwWJmU4y84opurc9hXN pHtIs674QMHKRSVTK3QUS86rmeRDVq22zgr5EPfWTQ9lxmE0yNqY4w9laxwVQaDpB6/Gt26gquh TiMuDGsKIaLNCcts91L9Zrg9nJU4EPBeOQyrnf756hypfKF5ZKUsiQwndFyTy4nVzAe3CQWuTNU EiTXoF4plWe/+kdmatjD5NgkESx8m0i8xxdo1CaUdNM6b++EeL7v+duQDljNsFV0EjokB0pe5jy txa0aenW1NuvgHE1HYsMVSsDIglmwJL9jI3XeYnLrdnkr0jd9FXrdpkndVInVOs7B4p7sMnVVsQ wn18Kw5INa4e54qr4EPvFM/VRNeAu282MtfNFu8KVSMkQ== X-Received: by 2002:a05:622a:5149:b0:52d:ce86:1393 with SMTP id d75a77b69052e-52dd5cecc34mr115534681cf.37.1787232457641; Thu, 20 Aug 2026 06:27:37 -0700 (PDT) Received: from ziepe.ca (hlfxns010zw-159-2-239-150.pppoe-dynamic.high-speed.ns.bellaliant.net. [159.2.239.150]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-52dd857b6b1sm30570231cf.3.2026.08.20.06.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 06:27:37 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wx2nw-00000003ikC-1Lb9; Thu, 20 Aug 2026 10:27:36 -0300 Date: Thu, 20 Aug 2026 10:27:36 -0300 From: Jason Gunthorpe To: Marc Zyngier Cc: Steven Price , Christian =?utf-8?B?S8O2bmln?= , Sumit Semwal , Thomas Gleixner , "T.J. Mercier" , Benjamin Gaignard , Brian Starkey , John Stultz , dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Jiri Pirko , Marek Szyprowski , Suzuki K Poulose Subject: Re: [PATCH 1/2] irqchip/gic-v3-its: Zero shared pages after conversion Message-ID: <20260820132736.GC18100@ziepe.ca> References: <20260820105026.53208-1-steven.price@arm.com> <20260820105026.53208-2-steven.price@arm.com> <87wltlnfay.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87wltlnfay.wl-maz@kernel.org> On Thu, Aug 20, 2026 at 01:32:05PM +0100, Marc Zyngier wrote: > On Thu, 20 Aug 2026 11:50:24 +0100, > Steven Price wrote: > > > > its_alloc_pages_node() passes __GFP_ZERO to the page allocator before > > calling set_memory_decrypted(). This assumes that converting a page from > > private to shared preserves its contents. > > > > For Arm CCA with MEC (Memory Encryption Contexts) the key used to access > > the page will change, and so by default the visible data will change. > > The host could ensure that it zeros the page, but rather than relying on > > the host's behaviour it's best if the guest simply zeros after the > > decryption rather than before. Specifically in this case the ITS tables > > are required to be zeroed. > > What are the guarantees that we want to enforce post decryption? My > recollection is that the RME firmware cleans the caches to the PoPA, > making the data immediately visible to the hypervisor. Obviously, this > isn't the case anymore, since the zeroing comes after that, and I > don't see any CMO enforcing this. I thought any CMO stuff was principally about cleaning things as part of the MEC change? Coherency after the memory is made shared should follow the normal cachable memory model rules, just like in a non-CC VM? We don't need further explicit CMOs for that. Post decryption I would expect from all architectures: 1) Neither the guest or host take a fault/error when accessing the memory. ie the host may immediately pass this memory to an O_DIRECT system call and have its kernel read from it. It must not crash the kernel. 2) So long as the memory is mapped cachable it should follow the normal memory model visibility rules. ie it works the same as VM CPU memory prior to CC 3) Rules for actual DMA are the same as prior to CC, the VM is expected to issue its own flushes prior to DMA if the platform requires it. Given the requirements for #1, is there actually any case on any platform where the host doesn't *have* to fill the memory? Is there a platform with MEC that doesn't generate an error on reading with the wrong MEC? Without MEC it surely has to be zero'd in the RMM world, right? I've argued before that set_memory_decrypted() should be defined to return 0'd memory. I think there are real systems that *have* to zero the memory as part of the state change and this API is now forcing an extra zeroing. > I'm concerned that this relies on undocumented behaviours that may > hold today on some undisclosed combinations of HW and hypervisors, but > that are not guaranteed at all. set_memory_decrypted() doesn't really > say anything, and I have the feeling that we may want some hypervisor > specific hook to perform the correct CMO magic. I don't think this is > required right now, but I'm not excluding anything! I would expect any required CMOs to be part of the arch's implementation of set_memory_decrypted()? Jason