From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793069821; b=X2LUuaP1IpqV6+JVp+ombjdhRrg9WewcZ9p3QiEN8HIQRPxI7vCF2WvAz8CEOdXAAm2w Epnm81vNDuwvATxQsUgdk+6gdMeSsd88MVb5U+gMRtIdc5i2tPIkjbqeSvz55EBzJol/B V/hMsVw6MHQ9SxN7W2GBdnO5Rg292+iqcwhNcNRNJRHF4bizck5tA213+jvFG27uQlLQj nG3BeCdc8nCoTq2vp87xjvM6oPwdKKCxpxY8sRejdNj/nleZZPpqUEIP5/ycVzhiWz/nx F4eTFSo7NlJcOI89EIlFBiOpbm80178oI4Njc7wNgZWls4IcMRbhAxvO4/e5x218EMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793069821; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=CMgB+FzrQPZBtoyno0UE3jQCmYhoPeFOpiZUNmu3S6w=; b=rx91yVT/FqBOu9BCXKrAGjkh0rlo4ddLfbEVGRMVHT3Hfx98BsBRGwPgsd3/ByWzHinQ /jftigzd6TS/vl8rfmmmd7cjSCJZSo7hehQLbitviybHiP/KdAD9ZZcDtjaPfIzwmviWX YbzikkNadk0ssU9yopij1OKvXitCkcizxcjQUJvokLwJ2TGGkq+leDJz4JqVcSmmvLwiv PyEOMogXpu16ttp60bva2F4ZJCzaNQdbP68BdOoiZDARV3XW/Vrae9Rkq87X3qjFcyEFp ioCgJJnC9Q6lLjngHzaQsJvA3xuRXvSUGK/ODfnF/9Vkj/G1WhcFVm0Widj8SxuihMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kevinloughlin.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=kuK+jZ60; arc=none smtp.remote-ip=209.85.167.198 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (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 5301F60A3820 for ; Tue, 27 Oct 2026 02:57:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5301F60A3820 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kevinloughlin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=kuK+jZ60 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-4c307941971so5068233b6e.1 for ; Mon, 26 Oct 2026 19:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1793069820; x=1793674620; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CMgB+FzrQPZBtoyno0UE3jQCmYhoPeFOpiZUNmu3S6w=; b=kuK+jZ60O5kkR8qvTjPWlwfNFqA0hINqgr5KdWNji68KBSi/DjquQq+Xsa/324lZLE gAIJJ9i0nUCAr9FpY+unKcy4PmPIgR+cM+r4PafxmkLdxSae8KVPOwJ+cHd1StiJWj8d Lb4Hc2QOAJg3SzDdK3zFWDErko1sJLAduFCV/AF9yBOVxVUjkmCBymlGDYcjMAL/ilvU q75nIVK6x5wLDVSSdrhKTQGHtljrfWRYn94YYG4TjmbGPyqA+fPP/KzGH0DRlXXZgSni EAZiWR4u7B9y1x6iP7Mh6sru1gz+xk6sNfKL11WvZ56arHRxhteISaO3EprO5OokELfW I3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793069820; x=1793674620; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CMgB+FzrQPZBtoyno0UE3jQCmYhoPeFOpiZUNmu3S6w=; b=UDPjd+t+7mOG+ZnubiLfcCo4oIeHbrPTue5ZKui4sPd+T7Pj+BXzBDbTwaXzLYJ4lw 8ZgFv5QGxglmhFA+O7ZHFxr0+5wxHadrK5mUmhQcambwwmd2XtURP9BNH3qgTF+EsVGn HN1pB705CVFtu87HiDbT78ehB8c9sHNeUbMRN+uR54SumzBj3JJZvt2R05S2U1MRYted CF16VDg22nzWYaLjpI+AKviOJQtm7uqfUDyiTiUbOFmNQN0yLGJWmbrJgPODH6BA4U5/ UgPjihRDyYpMl9+jAs3njmOMn6pK7FoKgzBLaOGHz/i4pVn0XvYgdJGddB4D9skk8mjB SF7w== X-Forwarded-Encrypted: i=1; AKwUvBxS4Yvv5SnWjWRT38gC2FYM5+CASGHsDrjU/nu2y2GueOmokfa9RwdLHnnBhNtV6H35M3xA48Wk8eGgReg=@vger.kernel.org X-Gm-Message-State: AFq9FYIBpqqIu08WUlh1iqH26MhduGfx2FHwenF9fWibVKfq7ueY4CRU KIJHDjhsRjw2eQx3PvtTD823peJ2PCbVBMehI3nNlucYUxsxCglMOFJZtYz5LJ5YyjYIFsigDmU 4OrCvJ9BarOu9oWqm1tCfF4occ2kOfPShOA== X-Received: from iovf14.prod.google.com ([2002:a05:6602:38e:b0:9c8:5014:752e]) (user=kevinloughlin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:50a3:b0:549:e9e3:9490 with SMTP id 5614622812f47-55c0023237emr5583862b6e.23.1793069820114; Mon, 26 Oct 2026 19:57:00 -0700 (PDT) Date: Tue, 27 Oct 2026 02:56:15 +0000 In-Reply-To: <20261027025616.1632690-1-kevinloughlin@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261027025616.1632690-1-kevinloughlin@google.com> X-Mailer: git-send-email 2.56.0.307.g5fe7bd680c-goog Message-ID: <20261027025616.1632690-13-kevinloughlin@google.com> Subject: [PATCH 12/13] virtio_balloon: unaccept inflated balloon pages From: Kevin Loughlin To: "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , "=?UTF-8?q?Eugenio=20P=C3=A9rez?=" , Xuan Zhuo , Ard Biesheuvel , Kiryl Shutsemau , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Tom Lendacky , Ashish Kalra , Michael Roth , Rick Edgecombe , Andrew Morton , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Alexander Duyck Cc: virtualization@lists.linux.dev, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sidharth Telang , Punit Salian , Peter Gonda , Ackerley Tng , Jacky Li , Steve Rutherford , David Skidmore , Kevin Loughlin Content-Type: text/plain; charset="UTF-8" When pages are allocated for balloon inflation in confidential computing guests requiring page state transitions, mark the allocated pages as unaccepted via mark_memory_unaccepted() before notifying the host VMM. When those pages are later deflated and released via put_page(), the page allocator routes them to zone->unaccepted_pages for lazy re-acceptance on demand. Signed-off-by: Kevin Loughlin --- drivers/virtio/virtio_balloon.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index e10bd792ef7c..217431e75751 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -329,6 +329,15 @@ static unsigned int fill_balloon(struct virtio_balloon *vb, size_t num) unsigned int pfns = (1 << page_order) * VIRTIO_BALLOON_PAGES_PER_PAGE; list_del(&page->lru); + if (virtballoon_cc_needs_state_transition()) { + unsigned long page_size = (1UL << page_order) * PAGE_SIZE; + phys_addr_t paddr = page_to_phys(page); + + if (mark_memory_unaccepted(paddr, page_size)) { + put_page(page); + continue; + } + } balloon_page_enqueue(&vb->vb_dev_info, page); vb->num_pages += pfns; -- 2.56.0.307.g5fe7bd680c-goog