From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795446045; b=E2ThwJ1gYSgbjDhSa1s8BZDzKXwvAWLgv3NDO654u15gRywzP81DgPdtEwJ3TazTUcpg St5sg1uhB0AknZNhq+/2wtSSQCxrwX40gS9SKEqm8x4qAxaDI761Tfw8h7qbRuqiQnjNd l41aVjCg7kDGI0EL7cmv9ayPFvN60zlaSFJEN4OEy1tJ+7fKvTXjOcE7Or5DrxyVt2ZIN JkMdOSLjJ1eUiWBj7fiUudKsW1WU0t33TxxZlPNAJXt/RmaZDGD7OnL9o17oSo+wwTSYQ KdIClR6An7bGLkXMMjkN+F3upQyHwC8ItCUrxHr0z/4BMm6HZF7PM5GVgfKrkGEEq6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795446045; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=8YXzoVkoKKTn5S6189qRHpEA8zSaXUAPSQ685ax1F0I=; b=T0gifBWC/cM2ttY/lyCWhymnH3PeuaT4FbLwqKAEgbLHs8FZhbRSZVPvin8GPGLvfrmK R3datDYwjJV87jjBDj0FPgwFzyhTwqcCky0Aim4ucl/ujCzrrHLHRhVZxaWynYVIXP730 WSXjDDU4R5KldkfJbrTz82SiHmKwryat0idYhuIpOOEEGH4OdsFd0S+iVN7eS0ufY973f pEFrlaehRVSDyWD8OInh2H+iyrThC/6krFBmeeg8Z6CrLIRe1JxTyc8uChfkX3ZSY8WkL Lkq5AcfjbKQH457UWyz9fDb9FUlIRda5dAX9D/DSy/u8UFDWCyLO4lzZi1Kbs4Ho+cQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass header.d=ziepe.ca header.i=@ziepe.ca header.a=rsa-sha256 header.s=google header.b="Js/hN7BF"; arc=none smtp.remote-ip=209.85.219.50 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A67F606A6A6 for ; Mon, 23 Nov 2026 15:00:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3A67F606A6A6 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.a=rsa-sha256 header.s=google header.b=Js/hN7BF Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-9212dac247aso36737306d6.1 for ; Mon, 23 Nov 2026 07:00:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1795446044; x=1796050844; darn=lists.linux.dev; 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=8YXzoVkoKKTn5S6189qRHpEA8zSaXUAPSQ685ax1F0I=; b=Js/hN7BFiz+V59LU3g3qClRYtgCYYRyqOBkW49G+CeYW1aEcatOFKpUqNmDa6nwoLO EEbZijW6BaZXx7xFQ+7bBLUFNphUSNLLEct5ENjAr5bCyRwBr03momZfim1ZfRs7R6og IuK9n0r/YinKfN0nFoXlYdgmv3JMxrqeV/+rOki5A6zQ16unhdz3qvXlQtHAnyXaCKAw m15ayg/ihxXKoYaonVGoEZTjRJMfkV25c4wJHR9yhGd4A7pVyaHJkb/UtBalcU5uuOxE BqeYptVjjfg+ensmZldQmRMXh2aVA2slv7fdKgNyHhoTrDbMjjhC7R6NhJfv1zKy/aIf S95A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795446044; x=1796050844; 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=8YXzoVkoKKTn5S6189qRHpEA8zSaXUAPSQ685ax1F0I=; b=W5n1VrqWRKJhkYPp/ydjCqkwmH1UBJKCCzC7Yng/nRVMjhWcuEM2a+whvbMj+AMbcA Cb3SyG1JqF8WlQ9ZYAcF9G5tILps+frcPpUBLriooOAYWjk5lSP6Nz9PkmSbjDv3tbVb 1k0Q9D01e4igs4mkBjIi08riT6gPJin/itA74afK5vsVsOkVU3lfQTZNwyFjG9/6iug+ B4aXFFUV5qpsYWqORJlCUZJwsE+CzSDcMNAGc3Rqjh9BypJAxpIxukfzA60PsSX2iRxw urpjg7VpognODLsPSkX+7lPPAvmopv39X6jZOaqJJVwcz3zaH2gETdvcq4iXko1fkZYi icJg== X-Forwarded-Encrypted: i=1; AL+hErFiwEQY88zGE4qCqh0b82h6OD1xExRbsH6vLgEj+zvVvdx3QvE0hD9UQPkieH3eh6DGSY6tprhauteo@lists.linux.dev X-Gm-Message-State: APuU4Z8R78OtgeVLSt64jQHLI/TwVOl9X9yZKLcTsAuexJNzbB7Qu8hh uGIGavf+KglsOuJceAu+kLA8aBH+7gdL1eTL4TWZ3X6aQQzUk4OlmE6Du9w/iDbbi4I= X-Gm-Gg: AZFdTZfnZFBkBKJw2+IJC6wgN6BUU0gqRvoQgPu4IPvZnRi2f05kHpjjpOwOvxFYWe/ RnzeQmZd7oGo+kap3ghKyWsGt9jegfAzauKg6dH69Yt63/fqoSxwzmRt9pvBzoRHwKFDqLRb5ku c/k+gFNyiQKKv4nsZiLIUEe0PL2/2KnwoA3+/AkznqynbAa29RrVfu1da9jsXazZts2a9PIXM7h om0P/x+8H882pSzwfXE+ON623Fyg4zejUrqcr131VNkkzz9I+vSVysH0ZuN82cfw+Kfw9z4L7Z2 4LPfZQ8wf13pHwoscW4gyagvMXOBCboc6/T3zsWOvehcHz+BuKK/yHVEYSlrlwfjoBhUIgN7W/q CWItEAVKDPPcbmXcZYT6zAY5F2miwLqahJK6gQxFHO4GL271Kt3KrTD9/QDK8G+TaobP41q+DRP qbY8uik+lirHW+UTnun+Y00S2MSTmd0Y3bhkZdviAiXe4bB1D//iPtk1u0c10LfzJh1SW31d7tR D/5h46Bba6htB38PILwDCSdj4fKZxHVSWqSm2WaSTp6gHa/te5NpZQI/UJIJyJ0EbgiiC0I2qBb tnl7HBrsXa5tPkfCprA49r72pIN51+qylApY+eAxDG0BE7Ritod7BRTpA5xQKXpJ7XVX1lUb7cz EG1M= X-Received: by 2002:a05:6214:4891:b0:921:27c2:3f89 with SMTP id 6a1803df08f44-92134a3715dmr207386236d6.17.1795446043629; Mon, 23 Nov 2026 07:00:43 -0800 (PST) Received: from ziepe.ca (stjhnbsu6iw-159-2-142-59.dhcp-dynamic.fibreop.nb.bellaliant.net. [159.2.142.59]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-92134a16754sm107600476d6.39.2026.11.23.07.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 07:00:42 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1xVVX7-00000000rK9-14j4; Mon, 23 Nov 2026 11:00:41 -0400 Date: Mon, 23 Nov 2026 11:00:41 -0400 From: Jason Gunthorpe To: Catalin Marinas Cc: "Aneesh Kumar K.V (Arm)" , linux-coco@lists.linux.dev, Andrew Morton , Baoquan He , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Christian =?utf-8?B?S8O2bmln?= , Joerg Roedel , Marc Zyngier , Marek Szyprowski , Robin Murphy , Steven Price , Sumit Semwal , Suzuki K Poulose , Thomas Gleixner , Will Deacon , Russell King , Benjamin Gaignard , Brian Starkey , John Stultz , Mark Rutland , Radu Rendec , "T.J. Mercier" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Ritesh Harjani , Shrikanth Hegde , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Kiryl Shutsemau , Rick Edgecombe , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Paolo Bonzini , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mm@kvack.org, kvmarm@lists.linux.dev, patches@lists.linux.dev Subject: Re: [PATCH v10 04/13] irqchip/gic-v3-its: Allocate shared tables using CoCo shared memory allocator Message-ID: <20261123150041.GB179082@ziepe.ca> References: <20261116091137.94252-1-aneesh.kumar@kernel.org> <20261116091137.94252-5-aneesh.kumar@kernel.org> X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 23, 2026 at 11:05:23AM +0000, Catalin Marinas wrote: > > - /* > > - * If set_memory_decrypted() fails then we don't know what state the > > - * page is in, so we can't free it. Instead we leak it. > > - * set_memory_decrypted() will already have WARNed. > > - */ > > - if (ret) > > + if (alloc_cc_shared_pages_node(node, gfp | gfp_flags_quirk, > > + PAGE_SIZE << order, &mem)) > > return NULL; > > > > - return page; > > + return mem.page; > > This part is mostly fine but I do wonder why not make this alloc > function the same as buddy alloc_pages_node() - return a struct page > pointer. I'd argue we shouldn't even be returning struct page here, do many places even use the struct page? What for? Exposing struct page to places that just want a kernel addr means they have to call page_address and we are back to the highmem weirdness. > > static void its_free_pages(void *addr, unsigned int order) > > { > > - /* > > - * If the memory cannot be encrypted again then we must leak the pages. > > - * set_memory_encrypted() will already have WARNed. > > - */ > > - if (set_memory_encrypted((unsigned long)addr, 1 << order)) > > + struct cc_shared_layout layout; > > + struct cc_shared_pages mem; > > + > > + if (WARN_ON(cc_shared_calc_layout(PAGE_SIZE << order, &layout))) > > return; > > - free_pages((unsigned long)addr, order); > > + > > + mem.page = virt_to_page(addr); > > + mem.shared_size = layout.shared_size; > > + free_cc_shared_pages(&mem); > > } > > Here it gets weird and I don't see why we can't have just a buddy-like > interface. The kernel-doc for alloc says that shared_size must be > retained for the corresponding free but without reading the source code, > you can't tell that cc_shared_calc_layout() gives you the same > shared_size populated by alloc. We have a similar pattern in dma-buf but > using the compound page order. This makes sense, we should not be passing size to a free function, make a compount page/high order folio instead if the API is going to be struct page based. > We can get rid of layout and mem structures (or at least not as > part of the API). Of course, this assumes that the shared granule size > remains constant for a guest's lifetime but I don't think that's a > problem. It should be encoded in the struct page meta data, as the order. > Was there a caller you had in mind that needs the common allocator to > share less than the whole buddy block? If we want this it definitely needs to be a void * based API not struct page one though.. Jason