From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246648; cv=none; d=zohomail.com; s=zohoarc; b=dAn1V/gWzn6iOn4ntb5vbqJGm5nlnjfMOYQE4b+aCOH+ASvluV1lWaf0wGqS9n65C1SgkzYG9NFCHhDAu2kwO+wvGPaT99pN6Tx0ci7BT3Do19rJjgukXyVaHekfzmRsfhihnGrk6ZYh0u1NDIHL1q/Cs0lRDEGA3fXFLCcM5nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246648; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O19QP3xK+jBJGuTPifAq7K+sTyafDuxBrZmdycbbFB4=; b=ajBHsh6eqYd5my6fNZKqIcz4F+1BV8Q1qreNr4sfTeRWh90kaJuq/JxATaXMaXlKXZ0NKQOr1OJj0LbTZ1PaUTwO8g+D/yq7tmenW7Gt3kBXCnUS231dpLWhkBtS6Dh1XT3oGquO7dPR+3aCrcFlELr0j3ARpwLSPOhTADEvUh0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246648597404.03573665810893; Tue, 28 Jul 2026 06:50:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374242.1621270 (Exim 4.92) (envelope-from ) id 1woiCT-0005mg-HN; Tue, 28 Jul 2026 13:50:29 +0000 Received: by outflank-mailman (output) from mailman id 1374242.1621270; Tue, 28 Jul 2026 13:50:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiCT-0005mZ-Eg; Tue, 28 Jul 2026 13:50:29 +0000 Received: by outflank-mailman (input) for mailman id 1374242; Tue, 28 Jul 2026 13:50:28 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiCS-0005mS-G2 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:50:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiCQ-00BQxQ-DA for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:50:26 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b38b-5cb7-0a2a0a5109dd-0a2a4505dec6-42 for ; Tue, 28 Jul 2026 15:50:26 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b3a2-4cb1-0a2a45050019-d1558034ad53-3 for ; Tue, 28 Jul 2026 15:50:26 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49558ce01afso29238695e9.1 for ; Tue, 28 Jul 2026 06:50:26 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c44b84edsm128749065e9.5.2026.07.28.06.50.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:50:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246626; x=1785851426; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=O19QP3xK+jBJGuTPifAq7K+sTyafDuxBrZmdycbbFB4=; b=adAUasnuXTgFIflJp5hvpDOhLBfCqhr1WHiLCRrvl6vNO4EVJDz1N7WKWqkxAXrfue jXnCueHCmjyQOaRgzOIEdAc/ZZ0DjbuZbKcu7UyFu9KWCMGnjW1SffwyCeEI6k9Gth1w mpXjnLndR4/SlS/Mr1fYI1vLNi1dnSdVsiKT5DtrL2ryDCMteZQA2NBJiBtKnS8TdpWx QetprwQgFYBJ5UEgG7UgjBq6efLAztQw5bab+GNhNIWWrfh0udI8c9GuLa9IL1HHuJyJ d80DsHsZPnOHG4ZRlWeYc3xRuS2oamhL/6qjJ4VCekTZ4SYqoRCGk1FWcHfaZTLCOuP/ IpQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246626; x=1785851426; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=O19QP3xK+jBJGuTPifAq7K+sTyafDuxBrZmdycbbFB4=; b=ExR4QPmmnjALEUa3icukNJ6nQUG7+PUb1dtEfoxPGW1cExIbwYfjGXlKa/EBFCHdS7 UDl/2LK1CTTFsOQRiVgMzcyClpcdrADTCMxNgO0yFPnSdRVMEyhg0kc6Tgw8+eq7IDMh 6Ja4kk8kosg6o/XZim7b1pw6mUl7daBlEuRnyR9ha2nxO3ecjdQAWZrSPRAPMq+MtHqi mKqjGpjUQcOjEsvTH1iwrfr1ERg37Ur9nBIdXmue8hk/TZMsNOtNCvFRrALO9j+7ugo7 gmNxmxkGJEEu0CvvdNVKdel2XxsboU5060A+fFMv8PddSOZOYWLaDmlQ9apM4nWItts2 3o1Q== X-Gm-Message-State: AOJu0Yz81Np9YzY0o1cHA0P/pCjg+Y5ExneOu4MOGGg1ifGlEDmwbGMM z4NfqaTD2FNPZ4C4CmIC1KlgaZ6YG4tgVrAvxVQbmPs5T6lx/xa3gujm8ZuxrBKgGUnvSIHAb9t OvaFpBA== X-Gm-Gg: AR+sD11QckNunU2VI81SUMaWiWk9o2N9C0MAB7d5ulGPYaIsfP3FHauRllww4vcb1pC RfU4fVjHem924oFcIHKLI0DCG0SoL4/wms7mccsJV2aNwB09wtvOthgrYUrIEtMp5l3MQEy2jt0 mVVGptnUQ7PQnA4NuFyKbF+0ft8EnvbhuleYuj7xncrBXFWUxOkYu99TlDy7iekr+rtq6UioIfW xSSqS3Ofk5eSph5Da6En7R8IwK78RuAeJr9gTbih1KysDhYMtCe7wJ7HZuYZ7oN7C0LEa7LBvut c4mE88GSFilC9LFBGynpHPIi4oavg1MT8hMqrOOlRH//3atLaqzxqJpurzGO2uP4po7A2bMYqk7 H4TC+Xp8ouGi0Uj5o5PfCLdZGjWHQ3fpR7pwEDCA8/B0AosFcFrbcYzBz1pbFiIr0X9J/FhEFcP QszqWvwPzBQQLH/M1qp24zVb2f1SYXd7LIExMkgdk2hMB65Vlf0UqIKIcj/mkhrieSNOpSaMlKL C8x X-Received: by 2002:a05:600c:c8f:b0:495:6b55:f938 with SMTP id 5b1f17b1804b1-496c642200emr27255995e9.10.1785246625683; Tue, 28 Jul 2026 06:50:25 -0700 (PDT) Message-ID: <6b05328c-7983-44fa-a1a1-bb81eed9615f@suse.com> Date: Tue, 28 Jul 2026 15:50:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/7] gnttab: add another compiler barrier to acquire_grant_for_copy() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1785246626-24D1E2A1-12E7E466/0/0 X-purgate-type: clean X-purgate-size: 4105 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246649748158500 Content-Type: text/plain; charset="utf-8" ... and mem_sharing_gref_to_gfn(). Like for the fetching of trans_{domid,gref} in the former we ought to also fetch other fields exactly once. Signed-off-by: Jan Beulich --- Strictly speaking mem_sharing_gref_to_gfn() would need another barriers added on the v2 path, but it being different sub-fields of the flags looks to make the uses okay there. Thoughts? Note that the calculation of cache_flags in map_grant_ref() has enough of a barrier after it already, by virtue of active_entry_release() being called right afterwards. The fetching of the frame in gnttab_transfer() is hopefully good enough, by each fetch happening exactly once. The sole risk there is load tearing, which can occur elsewhere as well. --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2606,6 +2606,7 @@ acquire_grant_for_copy( grant_entry_header_t *shah; struct active_grant_entry *act; grant_status_t *status; + unsigned int shflags; uint32_t old_pin; domid_t trans_domid; grant_ref_t trans_gref; @@ -2655,8 +2656,11 @@ acquire_grant_for_copy( status =3D &status_entry(rgt, gref); } =20 + shflags =3D shah->flags; + barrier(); + old_pin =3D act->pin; - if ( sha2 && (shah->flags & GTF_type_mask) =3D=3D GTF_transitive ) + if ( sha2 && (shflags & GTF_type_mask) =3D=3D GTF_transitive ) { if ( (!old_pin || (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)= ))) && @@ -2793,6 +2797,8 @@ acquire_grant_for_copy( else if ( !old_pin || (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask= ))) ) { + unsigned long gfn; + if ( (rc =3D _set_status(shah, status, rd, rgt->gt_version, act, readonly, 0, ldom)) !=3D GNTST_okay ) goto unlock_out; @@ -2801,39 +2807,34 @@ acquire_grant_for_copy( trans_gref =3D gref; if ( !sha2 ) { - unsigned long gfn =3D shared_entry_v1(rgt, gref).frame; - - rc =3D get_paged_frame(gfn, &grant_mfn, page, readonly, rd); - if ( rc !=3D GNTST_okay ) - goto unlock_out_clear; - act_set_gfn(act, _gfn(gfn)); + gfn =3D shared_entry_v1(rgt, gref).frame; is_sub_page =3D false; trans_page_off =3D 0; trans_length =3D PAGE_SIZE; } - else if ( !(sha2->hdr.flags & GTF_sub_page) ) + else if ( !(shflags & GTF_sub_page) ) { - rc =3D get_paged_frame(sha2->full_page.frame, &grant_mfn, page, - readonly, rd); - if ( rc !=3D GNTST_okay ) - goto unlock_out_clear; - act_set_gfn(act, _gfn(sha2->full_page.frame)); + gfn =3D sha2->full_page.frame; is_sub_page =3D false; trans_page_off =3D 0; trans_length =3D PAGE_SIZE; } else { - rc =3D get_paged_frame(sha2->sub_page.frame, &grant_mfn, page, - readonly, rd); - if ( rc !=3D GNTST_okay ) - goto unlock_out_clear; - act_set_gfn(act, _gfn(sha2->sub_page.frame)); + gfn =3D sha2->sub_page.frame; is_sub_page =3D true; trans_page_off =3D sha2->sub_page.page_off; trans_length =3D sha2->sub_page.length; } =20 + /* Use latched copies of the shared entry fields from here on. */ + barrier(); + + rc =3D get_paged_frame(gfn, &grant_mfn, page, readonly, rd); + if ( rc !=3D GNTST_okay ) + goto unlock_out_clear; + act_set_gfn(act, _gfn(gfn)); + if ( !act->pin ) { act->domid =3D ldom; @@ -4145,6 +4146,8 @@ int mem_sharing_gref_to_gfn(struct grant *gfn =3D _gfn(sha2->full_page.frame); } =20 + barrier(); + if ( !rc && (flags & GTF_type_mask) !=3D GTF_permit_access ) rc =3D -ENXIO; else if ( !rc && status ) From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246658; cv=none; d=zohomail.com; s=zohoarc; b=B5XvniV6oHMIT1uktCK5vggAkEKWbVN37yyJJ45WXbA7EmUzRKY5gruIXDMY20dfLJsIwq9ivQ0dilfbsOKc5I5nZoKJe7ONqzvJoM87JxXW5iYEGzV9DU/ShTcPwGTRB0zJU9EGtNJAL40ycliBTSMwXKNrRirWKtOY5tcJG+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246658; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VGDGiJPmLE14ZfHvAKCk4xWyMnkwoww93SfDim7yWaQ=; b=fyKYVvgTlRQt8svt6rbinLGgiM0dxE96yO20HPnzp5tqDIJ7YKYIRFWirPfr5944kPnVxaglQmbi3DZzyOj7c/pI1pFd6tNkTzeLtsHQVpZkKpM/JKjpq1nXjKnoMBQ7oSZcL8Cng/g7WAsp+G3I37Dcqn5f39OAvLf750yXZGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246658845632.2497461353157; Tue, 28 Jul 2026 06:50:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374244.1621280 (Exim 4.92) (envelope-from ) id 1woiCm-00067N-Te; Tue, 28 Jul 2026 13:50:48 +0000 Received: by outflank-mailman (output) from mailman id 1374244.1621280; Tue, 28 Jul 2026 13:50:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiCm-00067G-Qm; Tue, 28 Jul 2026 13:50:48 +0000 Received: by outflank-mailman (input) for mailman id 1374244; Tue, 28 Jul 2026 13:50:47 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiCl-00066s-4k for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:50:47 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiCk-00EvdR-Hn for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:50:46 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b3b4-2eae-0a2a0a5409dd-0a2a450ba9bc-10 for ; Tue, 28 Jul 2026 15:50:46 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b3b6-b7e8-0a2a450b0019-d1558036ad62-3 for ; Tue, 28 Jul 2026 15:50:46 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49558ce01afso29242115e9.1 for ; Tue, 28 Jul 2026 06:50:46 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c45ba4b0sm82523515e9.6.2026.07.28.06.50.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:50:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246646; x=1785851446; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=VGDGiJPmLE14ZfHvAKCk4xWyMnkwoww93SfDim7yWaQ=; b=WkvRLoUkTWG2LO9sbo7gqaI6+j3u3mBB6kGyP0bXzVSv7dLYbTzPubWjztRbyfmSrP rWlBxTDuxAk/adtMStVBpuPfWJ4B/AfAg+T0YYh82zu1MR7l5/iAENgMO1GV+pBJF0eS WwYMk/H3OopvPSRqOJKSe6yxQHyobiaz1Bn0BGdwZ8qqPMq1Dz+O+4FZDkKXDoXqaTn/ Vdd6rg3gHnO7AaSVEaOx7866dYGg0yGSdu/R2oqustXoxttZ1AAAr7NyxWuqzsaEtYSD 3vlgM7fdPk+XnkiwvNi0k+I/AHloCrbIP/aXJmm0VvmNbEN/5j4AEdg9zdQsAqKAYzT8 UBfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246646; x=1785851446; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=VGDGiJPmLE14ZfHvAKCk4xWyMnkwoww93SfDim7yWaQ=; b=Dfz1ysCG7Rr1ynzM7sdMDUTyAIlkQwxT6RvY/g8ag9KkRnvyNzGBx6btAzKL8efkWU Czd1MVGrBpWoggEa5QZ33e80Vhcd/7206KIZ+Gqh5Ul0WxKhw39u9PSYEQVJmD8CFue8 YHOLduszoYRLLm2RGKsEMeQ4lVY/s9oioXjfYz4Ztp1BjSukIBmskk+UKS0Z5cOEAO1H uwFV31cb2RBejdYsCnPS8egrhn2CjCpluVyBmVKddWz88EWix0Ot61MLiY+GxylCqTiz WRcjANVyUjt9rQ45/PwTMuFHrP6LUFq1jSAHRyULeyeUezcFcvb3jlwjW7tO5n5mj+dG Sxcg== X-Gm-Message-State: AOJu0YxYR2ijeXExwVmTk4aJYPDuAIu6vh13Tbpi+JYW/dNmLNHEpQeB cgpCguzhGDAp+Ynrd9qcRyF7JEh0EDJGHmMxcMfjQC64ucU/TpHhnh6unzt6+fhzb+adr4j5KMH a6JnPqg== X-Gm-Gg: AR+sD12hBF09fUNzUl3zE3n/DeF7lRCkBuP/0onZeOmsP3N0est+n9Aegu/lwaa+3kF Sfc80kThCUN2xZPd6dN4Imf9jAQ78P1asCceETKL89kYzk/nxBacmfAJ0Aj+mLfL6lwJC0nLFSy i/8ivVctZdBeFDxX3NttwgYMjCBgE1JF2lCYj3L5eLSk23RTJG7sz0pi/ftTBdr0asrO97MZk8A VZKiL6yitsJPX/84rrHepTGE9w1JBT7Q8+JwDl1IYYfNQyRc3C68YqixjYiWdUN4aE4hf7h64Ji 0wnxRrkpDaajVyOgUMo/C7o0M3ctHIbfvS+XDLoo4xNT/hAk2b8hMHIILeMDlLf8gowulbIuMKE jz48zlg2g775UhZMeH7ad2RAG4eIKpnnxbXgiErlosZNiei3HNwApZYeR5MXyXmP4lTomuxGfAZ Q0bqQfPjpIc7rfsdCce4z8XrJh5oGn8byl16Eo5FBSlwb4S/iXHBzSLEnedF47okJKckTNB/CGL X0b X-Received: by 2002:a05:600c:1c07:b0:496:c8d5:aa5e with SMTP id 5b1f17b1804b1-496c8d5aa8emr17145795e9.29.1785246645893; Tue, 28 Jul 2026 06:50:45 -0700 (PDT) Message-ID: <9ad78491-7759-483d-8ef9-91b026efb83f@suse.com> Date: Tue, 28 Jul 2026 15:50:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/7] gnttab: limit scope of transitive-only variables in acquire_grant_for_copy() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1785246646-A9EC69EA-3DEED1D2/0/0 X-purgate-type: clean X-purgate-size: 3238 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246659508158501 Content-Type: text/plain; charset="utf-8" Especially their use outside of the transitive grant handling code can be confusing. Two of the variables were merely used as aliases in the "needs pin update" path, while one of them was purely used because it's available in the "already pinned" case. trans_{page_off,length} remain where they are: They're misnamed imo, and would better be sub_page_{off,len}. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2608,9 +2608,6 @@ acquire_grant_for_copy( grant_status_t *status; unsigned int shflags; uint32_t old_pin; - domid_t trans_domid; - grant_ref_t trans_gref; - struct domain *td; mfn_t grant_mfn; uint16_t trans_page_off; uint16_t trans_length; @@ -2662,6 +2659,10 @@ acquire_grant_for_copy( old_pin =3D act->pin; if ( sha2 && (shflags & GTF_type_mask) =3D=3D GTF_transitive ) { + domid_t trans_domid; + grant_ref_t trans_gref; + struct domain *td; + if ( (!old_pin || (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)= ))) && (rc =3D _set_status_v2(shah, status, rd, act, readonly, 0, @@ -2803,8 +2804,6 @@ acquire_grant_for_copy( readonly, 0, ldom)) !=3D GNTST_okay ) goto unlock_out; =20 - td =3D rd; - trans_gref =3D gref; if ( !sha2 ) { gfn =3D shared_entry_v1(rgt, gref).frame; @@ -2841,16 +2840,16 @@ acquire_grant_for_copy( act->is_sub_page =3D is_sub_page; act->start =3D trans_page_off; act->length =3D trans_length; - act->src_domid =3D td->domain_id; - act->trans_gref =3D trans_gref; + act->src_domid =3D rd->domain_id; + act->trans_gref =3D gref; act->mfn =3D grant_mfn; =20 if ( is_sub_page ) atomic_inc(&rgt->nr_v2_ops); } else if ( !mfn_eq(act->mfn, grant_mfn) || - act->src_domid !=3D td->domain_id || - act->trans_gref !=3D trans_gref || + act->src_domid !=3D rd->domain_id || + act->trans_gref !=3D gref || (act->is_sub_page && (!is_sub_page || act->start !=3D trans_page_off || @@ -2866,9 +2865,11 @@ acquire_grant_for_copy( } else { + struct domain *d; + ASSERT(mfn_valid(act->mfn)); *page =3D mfn_to_page(act->mfn); - td =3D page_get_owner_and_reference(*page); + d =3D page_get_owner_and_reference(*page); /* * act->pin being non-zero should guarantee the page to have a * non-zero refcount and hence a valid owner (matching the one on @@ -2877,9 +2878,9 @@ acquire_grant_for_copy( * updates pin counts before obtaining page references, for * example). */ - if ( td !=3D rd || rd->is_dying ) + if ( d !=3D rd || rd->is_dying ) { - if ( td ) + if ( d ) put_page(*page); *page =3D NULL; rc =3D GNTST_bad_domain; From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246686; cv=none; d=zohomail.com; s=zohoarc; b=e84kfp3x9FKWoVzM2Z4aapp65GCyhqLORyY7ewqsrqTJ/04yHmvZU2Du2RTN4mmB83p+JuzJaNIS2/AJGzPFWaKQxPl1hC/z4F+/MHlR1KEdUYbDRjQIPVikORM2fZrgl9jNKe4cP6Of7rmX6Qkju6fBrG2YjbGLcok2vH+/Cz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246686; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VmsmB3SZeOUc6ARdQUTuy227vcpv9NvZgtecFoLVbnQ=; b=UoMQf48zU5wrTYUgcfpw190wcuVTTJhy7uhkLChMQjsE9h7kptgdbOcRPSkf8avXRcQ0kZGgQU+Wmn2/bCjt2+GFSbCUYHfZiHvtagwfGBPztsJqxvTOPHi1pG4xEDrNYVj9efpEBUhg2YLsqh9t1XOdr7h/bSe9XyyapU12xSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246686648251.98503337047953; Tue, 28 Jul 2026 06:51:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374253.1621289 (Exim 4.92) (envelope-from ) id 1woiD6-0006eo-57; Tue, 28 Jul 2026 13:51:08 +0000 Received: by outflank-mailman (output) from mailman id 1374253.1621289; Tue, 28 Jul 2026 13:51:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiD6-0006eh-1t; Tue, 28 Jul 2026 13:51:08 +0000 Received: by outflank-mailman (input) for mailman id 1374253; Tue, 28 Jul 2026 13:51:06 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiD4-0006cW-EY for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:51:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiD3-00BRHU-RL for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:51:05 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b3c9-5cb7-0a2a0a5109dd-0a2a4505837a-0 for ; Tue, 28 Jul 2026 15:51:05 +0200 Received: from [209.85.221.52] (helo=mail-wr1-f52.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b3c9-4cb1-0a2a45050019-d155dd34dc83-3 for ; Tue, 28 Jul 2026 15:51:05 +0200 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-47f92e3c14bso3499450f8f.0 for ; Tue, 28 Jul 2026 06:51:05 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c63bd3sm58862990f8f.27.2026.07.28.06.51.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:51:04 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246665; x=1785851465; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=VmsmB3SZeOUc6ARdQUTuy227vcpv9NvZgtecFoLVbnQ=; b=PlyahEoMAkNJnMPwvL3Afr4EX87EozkpBZrMqh9bwRT+j22wZcmw5rFeP624PXP4VA hetl9IqBI3UwcKeOVk3F+rWFf+7i+b+5o0KTOkYe4QtR3u8yi07PiWTg3xjyAd8+LtG0 S42qcEMwS2Kbxo9VRJVtp2FgDUx+0BPDqvtC1m8mjyv9sbid9oLKhe/6zQaGtq5UOkDC 9GjRMy263qsrIK7IHaOiAlgCObC56KgGaId9BsxlcktBiqhqEEHhy+ZmBXZpDxJG7d9c kMd58dvwUtS1gK1+DZUlVLGEmBnuZv6yniFmbLTpXAbhLZkDROAySdSHiFRQw4hOJoMq JaWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246665; x=1785851465; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=VmsmB3SZeOUc6ARdQUTuy227vcpv9NvZgtecFoLVbnQ=; b=NV7+gDKFHCV5W6HNWkiCssWgo0mJwH8jnAHOmwIlmddnU1LBQB+v8sFVAA3xq77LGS BwRHPlLOLK8g9mAxBNse/z1kbpK2rutR4B905w5PVId4UxLgxbVgaBsjrAHA++hxdikq H+1lVbK8BkKK1aBbbPgTBwEKPF8qdjoQwwo7+YQf7tiHd318Wc/Gp8OvJJT87T/EOS30 cPxTccpTWXu8FF2Ytt24dI4RQifD8d0Sv04vK+1DnnirX+UqWYnkiBCWt6T1Lm0zDqtR 8y/uGhNsxIl+UFxjVZ48WNHVTO/4xvjukpC4WBMVjvhCKUXFDkGeUx3Gc+xdrREgCJf0 2NVw== X-Gm-Message-State: AOJu0YyhN149SVWsse2Oqo6svorN6o5HFf/o/dr1aO4Edrn4KNA8AbXI kE5b74xlYITirWD0DU4f3nMg0QdtsutZK6xmnP/VuPfFiGfay+KsIOb4v1/WKZ6glui6NjIySOW QEh+Fug== X-Gm-Gg: AR+sD125B/O+S7iMuWHS/bESZ4L3iqy//EAxKA6k75G8caBLejVTcyihG89WgSVUEjH x6utBjLSjXWEJcORdk00fGgjWyy1RZmSubeaQUXWuzvWXvlhBWzknDCDZtr8M9WZQ2Y4Es1Eck7 NX2K2pKXPqx3i/ie+AXv43VlVIgdaQkxTqhQlVyFTPRqsP1/TxtpEFnW44uKApWERsVFQ8NdCok XNqOjcp9exf1t3oD2rR+w5rggMikSEBuQFgbKKTM+xdM2AGRwC0XpK6OblvaHUWzLir3TzBb3mF DPgs5y5euROi0xZqfw+411iE5kGN6YWOpcSaToVngGGi6zqGFCTxroF2e3K3ejoqI1dD4NiD9bz 2AYFuXMNa0yGljs77/HAuaR0s33qELn+7GNEzJvD4/07NARHqC+6nQqn+78me6a2KQRNe2OFEd3 wfHFq1gPfqAsK0uwVVxpG4ei6Ei4uyk2W47ywSzF7OXYsUw8brgF9xfRwuqzjIdXHgqQ== X-Received: by 2002:a05:6000:707:b0:47f:90df:4ec6 with SMTP id ffacd0b85a97d-47fb1e5ffa9mr2814316f8f.6.1785246665147; Tue, 28 Jul 2026 06:51:05 -0700 (PDT) Message-ID: <7392c56e-7250-496f-bb66-bdb6c04d3ed4@suse.com> Date: Tue, 28 Jul 2026 15:51:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/7] gnttab: fold redundant error code paths in acquire_grant_for_copy() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1785246665-F4EA12A1-19DF5A0E/0/0 X-purgate-type: clean X-purgate-size: 1370 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246687807158500 Content-Type: text/plain; charset="utf-8" One of the open-coded error paths of transitive grant handling is an exact match of the code at the unlock_out_clear label. The other can be made so by moving the put_page() earlier. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2729,10 +2729,7 @@ acquire_grant_for_copy( { atomic_dec(&rgt->nr_v2_ops); rcu_unlock_domain(td); - reduce_status_for_pin(rd, act, status, readonly); - active_entry_release(act); - grant_read_unlock(rgt); - return rc; + goto unlock_out_clear; } =20 /* @@ -2763,17 +2760,16 @@ acquire_grant_for_copy( release_grant_for_copy(td, trans_gref, readonly); rcu_unlock_domain(td); =20 + put_page(*page); + *page =3D NULL; + grant_read_lock(rgt); atomic_dec(&rgt->nr_v2_ops); =20 act =3D active_entry_acquire(rgt, gref); - reduce_status_for_pin(rd, act, status, readonly); - active_entry_release(act); - grant_read_unlock(rgt); =20 - put_page(*page); - *page =3D NULL; - return ERESTART; + rc =3D ERESTART; + goto unlock_out_clear; } =20 if ( !old_pin ) From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246703; cv=none; d=zohomail.com; s=zohoarc; b=cJmn3YBMUSYCYmiV5TPbdM2MH1a6YvskCSIyMlLh1JAJgxna1CYxnyQM0VUj1W/62/L7zQ/h1NQh0K3vA0W3Jeb5WYzWRMOj8Vh5OU0ze9u8Rzz4GsPUCVkZ/BXUam7InjKmr8Wy1q635s3y3r4fBS/G5m5qnlbY98scvUWlciY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246703; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mw7VsvfNJTXTcegWX2idkXl4Jj1/NWvy2zHyn00rWXA=; b=WdvJ1xo9rgOt+9yZrOV5RWHVSjEhlQ9NO48U7JyvCRzT1dE/mafk+i7y/eUcurnTKh5izOpNSylgIsV+8EUYFnXZkqGL1cSMIkLbUutk7SAUxIIa8983UzzAI/ySGxk2Sq6zXVFu2Gn3oGeB2ktKSACaaUfUIn8D0sG5bfHKBw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246702985942.297477220918; Tue, 28 Jul 2026 06:51:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374260.1621298 (Exim 4.92) (envelope-from ) id 1woiDS-0007Dl-CK; Tue, 28 Jul 2026 13:51:30 +0000 Received: by outflank-mailman (output) from mailman id 1374260.1621298; Tue, 28 Jul 2026 13:51:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiDS-0007De-9S; Tue, 28 Jul 2026 13:51:30 +0000 Received: by outflank-mailman (input) for mailman id 1374260; Tue, 28 Jul 2026 13:51:29 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiDR-0007CA-4w for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:51:29 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiDQ-00EYdu-I1 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:51:28 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b3d4-e002-0a2a0a5209dd-0a2a4505de42-46 for ; Tue, 28 Jul 2026 15:51:28 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b3e0-4cb1-0a2a45050019-d155802bb802-3 for ; Tue, 28 Jul 2026 15:51:28 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so23621965e9.2 for ; Tue, 28 Jul 2026 06:51:28 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4957bffc501sm250222935e9.4.2026.07.28.06.51.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:51:27 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246688; x=1785851488; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Mw7VsvfNJTXTcegWX2idkXl4Jj1/NWvy2zHyn00rWXA=; b=EuUOjQSwyOnANwlE/lyXstis7npwmig/W788G+QJaYNXFDPb0JjJJS8Yd2w61BgM92 3BLP1tmDgVG+49+0SH4wZ+99GLk5CFxvg50iVW8Ec0lIaON4TcTfeVR8Qr9yudP1FsIi PfrJkWlr0QcQzjWExR83RxZ+C3jzmyAMo84RnEZ2w6655mjBeJxAwjdco2+E62tUn8ZS l8kpTF5jpe0CVzO4E2y+CMfiukxsyAeOPwEFIH9+zNGW89thpVfFCSHjkjKEAX7YtIkl UU3T6WiY1XheUSTZxIpWopFZYVxKvs5ayg5NRrmbpLc6pkv/Zkl0GyE0agjB5pg4v1OO /5Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246688; x=1785851488; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Mw7VsvfNJTXTcegWX2idkXl4Jj1/NWvy2zHyn00rWXA=; b=hsHHfOz+U7BZOiQBZzFSlhw2MJjU3KnsECPTgsrnvO5MsiqIba6Gn76+wZNk2D+Jx2 /044yTRvUSZnL8bUXMvuFD+2j+eNznKxcY4Kf94iGffgIJ6iqb/636sdiGVh6mNAenKa jPXafp5zstPgDvRs87P5ony8ZEL3zjsJzts5so6GITeRUNR1GbJqu5lNypwxo/HAThcH uJKX6IAmc0fZgS6rh0RouL8KHAS6c7gx6B+7Ve0sqfCoQAbrfKbWsIdNtz1Exrwmc84v Gvm+Js4Se4Q+OpESVb7feky6vNGQEAQl3oyZcZb80FLjXXb+IA4khIIaf96zk74q0vhp 99aA== X-Gm-Message-State: AOJu0YwoYKBpyeAa1Z1JtX9tKr8b3DF0ERImt+TLDbaOYn6kqKvaz37k Rbta8hjdQXCo4tLKiM/9m+B0dZL7yshU9RRZ1lIdfbSBeDJuuCf1kb5rJvbzhNXxp3XXA9E0BNR Ckb4QTA== X-Gm-Gg: AR+sD119CEJwr9RdV2CvYzhSxJabSHc4XoCD3jcfimzPAr2c5N4N491XPMEHeBEzN4x pBfeG9UHqVnqSpkDlJSMAhEXH2XlJZerFr6mj7x8uKnhx8GaG8bCbVLVplPJgTfIS4dmBf/pZUd 2tt9IAiB0rZmo6qCgRhafS7RujaQ1qxxQhTQhVn4lgoobJklAg0hthmLYFeflR/Bc3jztcRGZWH pNtM/kuaLo15A+ceNGh7rfQUpO6bbyav6QzHcfqLe4K/355pSXRgfgyDU35xutp2ZrQQXvrwc6y uIwxuDTcKR7xCjKBCm7FymjVlPoMgEcDlTkirj9gUsRYnKQ57bjjj0vcc4kb66BOx5DIWC2LkCj hN4lR3VNxEnuteZmDZM0xFjVA4QQMWtkhLPjLlkWgzCWy7uFyVAEMLLUHN15JzhJOGWKhogt76+ rbZbJyb9OMn8SGv9KBfw7Y+KdJjdbI2tNQ/+7v15Ocj6i+9dgHzPBWtRgs4WZuU2EIJw== X-Received: by 2002:a05:600c:3e18:b0:495:71fc:3a64 with SMTP id 5b1f17b1804b1-496c6569058mr27439655e9.25.1785246688035; Tue, 28 Jul 2026 06:51:28 -0700 (PDT) Message-ID: <47051ab0-fce2-4c9d-8e45-ab4b598fc2ee@suse.com> Date: Tue, 28 Jul 2026 15:51:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/7] gnttab: use available local var in map_grant_ref() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1785246688-6BEB92A1-013C0595/0/0 X-purgate-type: clean X-purgate-size: 746 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246703739158500 Content-Type: text/plain; charset="utf-8" Commit a62776332cac ("grant_table: harden bound accesses") introduced a local variable "ref" in map_grant_ref(), but then didn't use it consistently throughout the function. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1324,7 +1324,7 @@ map_grant_ref( */ mt =3D &maptrack_entry(lgt, handle); mt->domid =3D op->dom; - mt->ref =3D op->ref; + mt->ref =3D ref; smp_wmb(); write_atomic(&mt->flags, op->flags); =20 @@ -1366,7 +1366,7 @@ map_grant_ref( status =3D NULL; } =20 - act =3D active_entry_acquire(rgt, op->ref); + act =3D active_entry_acquire(rgt, ref); act->pin -=3D pin_incr; =20 unlock_out_clear: From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246728; cv=none; d=zohomail.com; s=zohoarc; b=WXYLiG2dRqPlVffS3x88V4e/F4poY7Bm8sy5IvBXNIHejkUYdPiHrNrqhtxvPVhhMAz8j4kqiuSN1rrkXKRLEmBE/j3lmEbrBiiVYmIXFmZLLskpAjYCrYuhXQBCa/gXIYVsIki10W5iHfU651lX6SPrM/ssYndGSzux0RkOJ48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246728; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wUqQLSl9FHIBU5/My3xhEwCWgDaa9Jd42rl/ByxW6kQ=; b=K2jVUEJLPjTKlxHSNCDwwMrGkVUzSWMZZaczq7PWzbe/QXx8EZJirhE64JOTamGw9sOQNYqRR6fGglyvwuf16gvxR64XkgBxa3KKyg0SgStymTZ3IVyIGvR0ulTuUjrg5tbIGetrZsOrFkDLanvw8M6j0ScDcsjSa4zvFCenIaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246728103297.9713705968883; Tue, 28 Jul 2026 06:52:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374265.1621307 (Exim 4.92) (envelope-from ) id 1woiDn-0007gt-L6; Tue, 28 Jul 2026 13:51:51 +0000 Received: by outflank-mailman (output) from mailman id 1374265.1621307; Tue, 28 Jul 2026 13:51:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiDn-0007gl-H6; Tue, 28 Jul 2026 13:51:51 +0000 Received: by outflank-mailman (input) for mailman id 1374265; Tue, 28 Jul 2026 13:51:50 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiDm-0007f2-Ja for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:51:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiDm-00BRgj-01 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:51:50 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b3f0-bab6-0a2a0a5309dd-0a2a45029e8c-44 for ; Tue, 28 Jul 2026 15:51:49 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b3f5-6ca4-0a2a45020019-d155802cf133-3 for ; Tue, 28 Jul 2026 15:51:49 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49548aebcd8so28917165e9.3 for ; Tue, 28 Jul 2026 06:51:49 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c44afaecsm91547275e9.2.2026.07.28.06.51.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:51:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246709; x=1785851509; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=wUqQLSl9FHIBU5/My3xhEwCWgDaa9Jd42rl/ByxW6kQ=; b=MxvLZcwYmXivdiEQumix3L4dVZYhRuaBkGWx1Q0ZJ2vSeX+dhOE5YEE/eooQds258U YyaQqYA9FZmDV0IWbtJV3dVjclYm2wsSFUGXGgM4W5wVKvO/I8HtXQGO9gk79WmDStz1 yqmCNw1jqa+Kodz9+4uSwvyZxcC+oQmp2HYuOmDPkoyBcAv3Ucfzl6ePkHtm3JtbUegH Od42ISpvp6v6uDh25Wbz22LTpoo+PGS5ornvpPVF3YHKIVdGYHNvt1Cw4BIa06Y4TPKz Y9jyhtVrRpEW7xOAxh+K/e5GzqI3AqL8Pwk3QmUFtYdWiGS/eH0sxgnDlm6kS3lfgdI+ oO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246709; x=1785851509; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=wUqQLSl9FHIBU5/My3xhEwCWgDaa9Jd42rl/ByxW6kQ=; b=OACL3oI/a3TUastLxURcz57PK5RapGvVRLuSiwY7GpO1cItA6y7hlrf6dy8dQ3xBe/ A3D2a+WwNGY/bh3zFV9GzjI/OoByI/nj7nREMFSUzM7hYIicVy8xqY1RUJIuFR+fCvi7 NpNLWqD42r7jASqn8V/qRIY5DvLCuU2gKKsT6oHH9h+ODWNJZaH8jlssLhjn/u9Tjhl9 kDOFTMwIBPDFNTMv4dXTB3O57QwDUuUCHfK35yBuK5ZZjdxqLh0VQCjcG1si9smCIQL2 Z7tVIBHNOBNjZ45xe8+eN38G+bB+07ybduo790jE+ySL1dtAjIjMFDZf5hfRNXkQBY2D TiYA== X-Gm-Message-State: AOJu0YyiMqzjyJ5yKuuNRniFSapYwK+qCCiC9NMyhMO36G0eAswy0uPy PoEuQ0cnQCgOjtpUdEDj9fdcg2xcIKH/WM2BBz286Deme+I9N4/TaIbvyOmJ5QJl6QYUBo6Kc99 Qpzm2Xg== X-Gm-Gg: AR+sD11U+800tUHHQ9dohDwBMnTsHFMNOiBEXZfvBFH24GuKcRIy5euEavIuND5lJHg oqqoiXtyu9mHGvYsaJnJrIebEEiPf9jWQJFYJYXhKPDg+u093ohpQVwxDgpT1tvH+uYm78z4TtC z0+BXI0/QYoZ8xq165J7pt+IJdsMRPqEwBTd4OJBXRu5VsDt30EiVpyt+6BGTMgWjubMox8P4J0 EHhqjtosN2ejaA2aBjbdNl+u6ROEwgo4eqwy/XdDkAOqVM8fpbjvU0TtQtid/+o7QhoapE2eu8g wwrX3JMbB5MHrV+5H16wUPXgsGPYrGmgcGTh8LEdYzOqcVFrabU5xnj5GA8llp6VUpOgEuygolK IcSvwA3UQ7wws+bst9mAITW0LDL8ymraPS0KPvk/VNb6DCoVuIvji6p99/hmSDUOy2bFPmxs5/Y FcwHtWi2tI3ytNL0SxEyLODBR8Jw9fDReViUO7bai2plnzvQ/byXnNrscqWyZM/3qqsw== X-Received: by 2002:a05:600c:3f10:b0:495:7278:95c3 with SMTP id 5b1f17b1804b1-496c657de59mr26303885e9.26.1785246709449; Tue, 28 Jul 2026 06:51:49 -0700 (PDT) Message-ID: <6e9d7bc5-3e1d-4262-b806-e59595f3584f@suse.com> Date: Tue, 28 Jul 2026 15:51:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 5/7] gnttab: drop local "ld" from unmap_common_complete() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1785246709-668B42AC-45990A5F/0/0 X-purgate-type: clean X-purgate-size: 1080 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246729910158500 Content-Type: text/plain; charset="utf-8" It's used exactly once, and even then only conditionally. No need to establish the value in all cases. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1606,7 +1606,7 @@ unmap_common( static void unmap_common_complete(struct gnttab_unmap_common *op) { - struct domain *ld, *rd =3D op->rd; + struct domain *rd =3D op->rd; struct grant_table *rgt; struct active_grant_entry *act; struct page_info *pg; @@ -1618,8 +1618,6 @@ unmap_common_complete(struct gnttab_unma return; } =20 - ld =3D current->domain; - rcu_lock_domain(rd); rgt =3D rd->grant_table; =20 @@ -1656,7 +1654,7 @@ unmap_common_complete(struct gnttab_unma if ( pg ) { if ( gnttab_host_mapping_get_page_type(op->done & GNTMAP_reado= nly, - ld, rd) ) + current->domain, rd) ) put_page_type(pg); put_page(pg); } From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246764; cv=none; d=zohomail.com; s=zohoarc; b=h5x0v7R8tjTzcbf4NXPK+YtQi4N3L0zYhJRrN8vldW9Snz4dNyyevD0sXEH9z+c1XVkbEqnFSDEMyjmW49psLZrwNZU1L6f4P5UEWUmf2xWlfr1OwjKPDwmxcm1ocwfxt+odWSLJd7NzNCmur2lyQ6tRJ4pDpyskUfU0cdmpe1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246764; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sjq1+NwUBvPK4RcSVOHsjrwrht1DWC2Q5O4CPfABIqM=; b=I0LdFqzRxBgrrd20zWrUBjt9SLK4cAwlgpSVOhGRT2zZkh6YAbimDihXiQKDly89K562KEguNIytLcm2NHcQYOYA8xCLm0684QVQ4/DNaoeecNQsuH10MZi+Nq4yeNKdMogZ9GpjwNW8VEk5zRf3IeqEqXt40MFIh0SB2bWIQAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246764835375.9568278481013; Tue, 28 Jul 2026 06:52:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374276.1621316 (Exim 4.92) (envelope-from ) id 1woiEM-0008LH-0e; Tue, 28 Jul 2026 13:52:26 +0000 Received: by outflank-mailman (output) from mailman id 1374276.1621316; Tue, 28 Jul 2026 13:52:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiEL-0008LA-U8; Tue, 28 Jul 2026 13:52:25 +0000 Received: by outflank-mailman (input) for mailman id 1374276; Tue, 28 Jul 2026 13:52:24 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiEK-0008Kr-Dx for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:52:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiEJ-00EYkd-Qe for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:52:23 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b404-bab6-0a2a0a5309dd-0a2a4503b880-48 for ; Tue, 28 Jul 2026 15:52:23 +0200 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b417-fae8-0a2a45030019-d155dd33a4c1-3 for ; Tue, 28 Jul 2026 15:52:23 +0200 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4758bd3731bso933323f8f.0 for ; Tue, 28 Jul 2026 06:52:23 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85bb5127sm55034291f8f.10.2026.07.28.06.52.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:52:22 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246743; x=1785851543; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=sjq1+NwUBvPK4RcSVOHsjrwrht1DWC2Q5O4CPfABIqM=; b=SI24Np5LbKlGkAOBvdOjHPyut1L+LTj+lwci/uT4FXx1Mnot569uAQDKVtbhxg1I+E UESOCeVLPdUYkR6zClhQkaDMCa4HCoG1F4sWs1mR+ova2p5gzxNqmjMb2zleGk+DR5lK 352DtF7tLd2aSShooPHmfX7GI8Xig+YiEyJ9konI24lhPXChVPFJs14se4BdWJRK5nJf lTFO7FpgK84j9lRf5AP7nRS+ARoDYmgEH7DyKgDeE9TE828Sqjhwd6eC8jmBAoAZRfri KgsVA4B//qNML7pUgwcbldks2HZkWttROlV/hs8DhVEMicRmXSN8qNlcVDsDSaOlIWiI x3Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246743; x=1785851543; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=sjq1+NwUBvPK4RcSVOHsjrwrht1DWC2Q5O4CPfABIqM=; b=nn3S87g/JNj8W4DGU3lO3MKJbTmWORa9lxLLcUoRZi1fAI1fA65xkqbz2prI4FsB3V gZ2FOy5yZyWZLyPSWYr4yRZHfbTXbQdQD/bitdLR6h9F0J1M6dNeVDWp4O8Zj+lOesIf QIiDoCynu41tq5+KgS9xZtfkc19K5b7GuILn3UJG/Rj8Yqq5ZXCcEe8MKD9id42UaumZ u5uN18tn8clZXKb8wID5qfsH+RpN150CqWM6dIfmvmGg7LC79TT78g0OJ14dlRAprFCp ++xY976qDt15F0W9HACbdQfmoRDbNEMPaubBQVoe5QihoNHQ9ekhUaym6qXefxqVlbei hUFA== X-Gm-Message-State: AOJu0YygVgnW6fWpTwuUqjJ/+/mwvt9QwgG2oRmXETa0zW2h/yYDy+o6 6qzeUImv3BkgkcYu7NJh8QVCm4O9BZRXzdFg3E8dbaC8fbI78YmrDNGn3KSrI0GPuxmm4bRGew/ Q/bpheA== X-Gm-Gg: AR+sD110HPKcig49NX3hHHy8skT4hCPZfZHPWqQj16ERunzY+4+QWXI66m2g/1KQREV NhLv+G5TNL8GxPa8LxyZT5kLqPK7aouQ1WCoSj8hi7m97cSBZQptT7dbrFZqvjDOxKn8C6X47qC ES6MGqJUNPwRntWj6a3/J57Jm0wNg4auSCVQ9YLg3mFZYQVx9z5aq4ALhks6rdoLZJUpKfGbcBq LtYOXCRkVZA36EPDtR6gGt9DcaID1TOPGMVLzJfPB8jqtPXT3KNCt1sjdhLmVbw7fCiBc71ysgA SqkA75D82WMjogmhHZglMKzojJ0gY8ChQ88WrBRB5tLzHGnVgPRViru8qVSwKol3R+N/bQLfRoi 8jyjH5jtuCqN8vgiOiMvtqGdG7F0K+yHsP4T6zbZqVAjtwHXSJ0UdFRS/jmya8yVhYibISIhpX1 fJdsxaLOR8PaVSVZCyE6SrnN3z5c4f1nIaVoDJNIyXeopTIUej/m/CauvTzX1OozSH3Q== X-Received: by 2002:a05:6000:41ed:b0:47f:8cd3:4bed with SMTP id ffacd0b85a97d-47fb1e8547cmr3258724f8f.5.1785246743193; Tue, 28 Jul 2026 06:52:23 -0700 (PDT) Message-ID: <06d74bd4-86f1-4c25-a6f7-f4e1c9de199f@suse.com> Date: Tue, 28 Jul 2026 15:52:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 6/7] gnttab: rename a parameter of gnttab_populate_status_frames() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1785246743-6F6C64E9-1CE03113/0/0 X-purgate-type: clean X-purgate-size: 1078 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246766171158500 Content-Type: text/plain; charset="utf-8" In a function of this name, "nr" (and hence req_nr_frames) is, at the first and second glance, the number of frames to populate. That's misleading, and it's also only what one of the two callers (gnttab_grow_table()) actually passes in; the other (gnttab_set_version()) passes the number of grant frames already in place. Fold declarations while at it, and convert the assignment to an initializer. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1807,12 +1807,9 @@ fault: =20 static int gnttab_populate_status_frames(struct domain *d, struct grant_table *gt, - unsigned int req_nr_frames) + unsigned int grant_frames) { - unsigned int i; - unsigned int req_status_frames; - - req_status_frames =3D grant_to_status_frames(req_nr_frames); + unsigned int i, req_status_frames =3D grant_to_status_frames(grant_fra= mes); =20 /* Make sure, prior version checks are architectural visible */ block_speculation(); From nobody Tue Aug 25 13:45:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1785246812; cv=none; d=zohomail.com; s=zohoarc; b=GILFROpqll5YVSk5S1kL+S528yoMU0nDXIf19KLU5FApF5HxQ8ICuJBMHo0LVCvqfIYqIo/PPr5mLOoz96trkyDsb5+ZQjH1LeJtnrUrRrhIAUwrICI7m5wp1nhSQEMI8dASxx8QUPujPpTwk9RaiLuA7gKNc5WApyhdkYPQHmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785246812; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7d/y3edQde9sNrzZI5Z21bvZ8131PvVZbw6OvYDGVRE=; b=CHfR5xKFU3f2qoXP8wVLYvb7CYSxu4ODopGHr0e9izMZlP05lwNvOp/fS+eri6dEV3QD82MPLLb1rMogJqyf3tY6yCbJdAFsmDTKujXS6jpNgDdmRM45zlzUTHiHWaWEKrFbTv/c4YnU0PuYGny/XX5iGloNLBfs3/CAVZJ2ItY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785246812715699.0685817445369; Tue, 28 Jul 2026 06:53:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1374286.1621325 (Exim 4.92) (envelope-from ) id 1woiF5-0000cb-95; Tue, 28 Jul 2026 13:53:11 +0000 Received: by outflank-mailman (output) from mailman id 1374286.1621325; Tue, 28 Jul 2026 13:53:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiF5-0000cU-5b; Tue, 28 Jul 2026 13:53:11 +0000 Received: by outflank-mailman (input) for mailman id 1374286; Tue, 28 Jul 2026 13:53:09 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1woiF3-0000c9-55 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 13:53:09 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1woiF2-007Hx9-Hd for xen-devel@lists.xenproject.org; Tue, 28 Jul 2026 15:53:08 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a68b42c-e002-0a2a0a5209dd-0a2a4507ca76-44 for ; Tue, 28 Jul 2026 15:53:08 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a68b444-b4ea-0a2a45070019-d1558031e50c-3 for ; Tue, 28 Jul 2026 15:53:08 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4957eefd361so28699575e9.1 for ; Tue, 28 Jul 2026 06:53:08 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c44af22dsm72996535e9.1.2026.07.28.06.53.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 06:53:07 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785246788; x=1785851588; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=7d/y3edQde9sNrzZI5Z21bvZ8131PvVZbw6OvYDGVRE=; b=cDshc/xJSTuTNxVGEDcXM4biXCyaLPgU/Miq20ufvXLtc5bOedHP0Dte1BOxKiufkk +fWo05ySE9+A2X3QGi7J/XREl0qQifvN2HyVnzhVyXc3zoMmDk1KQ+poqtleDzwcn/Rz ISuToUvDZxoRolRIOKJguxdQ/JykDVmdwEgdAobjUB6rHxfyURP2uGkAXRrJZIDdsG/j V/a7egxxEjMVAbazFYIKTxQcc9TFOAvHhMbDqNEpX+cjLkxwfw0rrxGC+wNwJNP+g0En PSWrPPVklGl/et+6vIlOta+5wsSJPA66YmLfLNUX1zrE3NgiXq9brrx3SQgH/nyTtZfl u3Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785246788; x=1785851588; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=7d/y3edQde9sNrzZI5Z21bvZ8131PvVZbw6OvYDGVRE=; b=XvpIM/EI9kWN7pOBUjef9h51kL/Vy2rrXfQ66IpvpJlRS5xcBUToZ1MLcdjutJyynN bOJYCRKs1TuSVpAaGA0L0sIPf203N+UhtvggAv+3DAqghByEh1f2yqIoB9ZLVrHtv4ck PK0dK6DMgsf21QuF9Pk5X6hrmReu4djH3ph5TMqwA1eHIwC6bfmCsUqVtgKjNt4luKUO 35KslNTqbUb7veOT4L2Au9Wh8OYZoX57MLKj2x4PZxP6k38LGVX/Q63dJja96fObAuff osLC/hias6EfL2Jaua4/1+XWMOqYKYcBk3Pn8vQO30pCERoXJ10BTVk+hrMh4UgGAVJ3 3W6w== X-Gm-Message-State: AOJu0YxLNfKZmCz1fGNMXHE0jVVQmitv5rGsI8MwXXFbetBIb44c6XCa Tu9rNDxbVgrpj55XVFiAnxs841CxioEfNkDp8+z97xvR8/x5hYJ9qidZajEtr9yt0araq8fwr2K uJFnUBQ== X-Gm-Gg: AR+sD1098aK5qdSEFjvOViJ+MdquQ9Jmqg+duk0fen38oucdUuA23IK5BLMmCq/9Yvj YsT5M8SSjYOWEuLKDSEvN41wdFmZXvPW9PJ+wtjfz5JDPAdtpdkPbEEDYeNo0A4reSxEgMHpDvu j9cSf7Z6ryFpHBnOVJkgg7qILynGdMow1gqiG4Wx7Ho//K00/K9FMOLKRUKH2ht6Wm8ZXwXroXX C+NcN4gP4F4/wfduVi/Z2pbIuBDoh96Ysik4H+e5/O7vDC4s+qxdxww8WZEYp2gbkrx2Y4VBhUB ZIgvYmj3qAsqpjhPxsBaxMEtB7nctJdxWrtssPnEBlgmMwTnjsktBZSh4CS/Y1iI+vpMI2t3IrS j3carly9v1Mn+Z45lPRmcz9d8tu1HwlZCwcQ1/i8eWM4XcHr21tZEBm4o1N8WVqw+gH11DTJqQj z5EhCGxuYEROw73lVum+tbfF6QqI9m09hX9k4Tusbm8gdMDz053YoJRwtpuedlcNqAYg== X-Received: by 2002:a05:600c:3b1e:b0:493:bd2a:93bb with SMTP id 5b1f17b1804b1-496c653d055mr27394725e9.3.1785246787872; Tue, 28 Jul 2026 06:53:07 -0700 (PDT) Message-ID: <436c0688-8b9a-4e56-9d4c-c81dcfbea56e@suse.com> Date: Tue, 28 Jul 2026 15:53:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 7/7] gnttab: unreachable code when GNTTAB_MAX_VERSION < 2 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , Nicola Vetrini References: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <38850629-8bfa-4737-99ff-0fd3f489e56e@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1785246788-A5AC0AE4-4BE619D7/0/0 X-purgate-type: clean X-purgate-size: 17849 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1785246814760158500 Content-Type: text/plain; charset="utf-8" I'm surprised Eclair doesn't spot the large chunks of unreachable code on Arm, i.e. violations of Misra C:2012 rule 2.1. Signed-off-by: Jan Beulich --- This pretty certainly isn't dealing with everything. For example, with another helper the gt_version field could likely also become conditional. With some more effort the nr_status_frames field similarly could become conditional. --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -72,8 +72,10 @@ struct grant_table { /* Number of grant status frames shared with guest (for version 2) */ unsigned int nr_status_frames; =20 +#if GNTTAB_MAX_VERSION >=3D 2 /* Number of version 2 operations in progress. */ atomic_t nr_v2_ops; +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ =20 /* * Number of available maptrack entries. For cleanup purposes it is @@ -182,12 +184,10 @@ static int cf_check parse_gnttab_max_map opt_max_maptrack_frames_val); } =20 -#ifndef GNTTAB_MAX_VERSION -#define GNTTAB_MAX_VERSION 2 -#endif - +#if GNTTAB_MAX_VERSION >=3D 2 unsigned int __read_mostly opt_gnttab_max_version =3D GNTTAB_MAX_VERSION; static bool __read_mostly opt_transitive_grants =3D true; +#endif #ifdef CONFIG_PV static bool __ro_after_init opt_grant_transfer =3D true; #else @@ -196,17 +196,24 @@ static bool __ro_after_init opt_grant_tr =20 static int __init cf_check parse_gnttab(const char *s) { - const char *ss, *e; - int val, rc =3D 0; + const char *ss; + int rc =3D 0; =20 do { + int val; + ss =3D strchr(s, ','); if ( !ss ) ss =3D strchr(s, '\0'); =20 - if ( !strncmp(s, "max-ver:", 8) || - !strncmp(s, "max_ver:", 8) ) /* Alias for original XSA-226 pa= tch */ + if ( false ) + (void)val; /* Nothing. */ +#ifndef opt_gnttab_max_version + else if ( !strncmp(s, "max-ver:", 8) || + /* Alias for original XSA-226 patch */ + !strncmp(s, "max_ver:", 8) ) { + const char *e; long ver =3D simple_strtol(s + 8, &e, 10); =20 if ( e =3D=3D ss && ver >=3D 1 && ver <=3D 2 ) @@ -216,6 +223,7 @@ static int __init cf_check parse_gnttab( } else if ( (val =3D parse_boolean("transitive", s, ss)) >=3D 0 ) opt_transitive_grants =3D val; +#endif #ifndef opt_grant_transfer else if ( (val =3D parse_boolean("transfer", s, ss)) >=3D 0 ) opt_grant_transfer =3D val; @@ -330,10 +338,12 @@ shared_entry_header(struct grant_table * block_speculation(); return (grant_entry_header_t*)&shared_entry_v1(t, ref); =20 +#if GNTTAB_MAX_VERSION >=3D 2 case 2: /* Returned values should be independent of speculative execution = */ block_speculation(); return &shared_entry_v2(t, ref).hdr; +#endif } =20 ASSERT_UNREACHABLE(); @@ -378,6 +388,9 @@ struct active_grant_entry { }) =20 domid_t domid; /* Domain being granted access. */ + +#if GNTTAB_MAX_VERSION >=3D 2 + domid_t src_domid; /* Original domain granting access. */ unsigned int start:15; /* For sub-page grants, the start offset in the page. */ @@ -385,6 +398,9 @@ struct active_grant_entry { unsigned int length:16; /* For sub-page grants, the length of the grant. */ grant_ref_t trans_gref; + +#endif /* GNTTAB_MAX_VERSION < 2 */ + mfn_t mfn; /* Machine frame being granted. */ #ifndef NDEBUG gfn_t gfn; /* Guest's idea of the frame being granted. */ @@ -405,6 +421,15 @@ static inline void act_set_gfn(struct ac #endif } =20 +static bool act_is_sub_page(const struct active_grant_entry *act) +{ +#if GNTTAB_MAX_VERSION >=3D 2 + return act->is_sub_page; +#else + return false; +#endif +} + static DEFINE_PERCPU_RWLOCK_GLOBAL(grant_rwlock); =20 static always_inline void grant_read_lock(struct grant_table *gt) @@ -724,6 +749,7 @@ static unsigned int nr_grant_entries(str block_speculation(); return f2e(nr_grant_frames(gt), 1); =20 +#if GNTTAB_MAX_VERSION >=3D 2 case 2: BUILD_BUG_ON(f2e(INITIAL_NR_GRANT_FRAMES, 2) < GNTTAB_NR_RESERVED_ENTRIES); @@ -731,6 +757,7 @@ static unsigned int nr_grant_entries(str /* Make sure we return a value independently of speculative execut= ion */ block_speculation(); return f2e(nr_grant_frames(gt), 2); +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ #undef f2e } =20 @@ -919,7 +946,7 @@ static int _set_status(const grant_entry domid_t ldomid) { =20 - if ( evaluate_nospec(rgt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(rgt_version =3D=3D 1) ) return _set_status_v1(shah, rd, act, readonly, mapflag, ldomid); else return _set_status_v2(shah, status, rd, act, readonly, mapflag, ld= omid); @@ -1089,17 +1116,18 @@ map_grant_ref( if ( act->pin && ((act->domid !=3D ld->domain_id) || (act->pin & GNTPIN_incr2oflow_mask(pin_incr)) || - (act->is_sub_page)) ) + act_is_sub_page(act)) ) { gdprintk(XENLOG_WARNING, "Bad domain (%d !=3D %d), or risk of counter overflow %08= x, or subpage %d\n", - act->domid, ld->domain_id, act->pin, act->is_sub_page); + act->domid, ld->domain_id, act->pin, act_is_sub_page(act)= ); rc =3D GNTST_general_error; goto act_release_out; } =20 /* Make sure we do not access memory speculatively */ - status =3D evaluate_nospec(rgt->gt_version =3D=3D 1) ? &shah->flags + status =3D GNTTAB_MAX_VERSION < 2 || + evaluate_nospec(rgt->gt_version =3D=3D 1) ? &shah->flags : &status_entry(rgt, re= f); =20 if ( !act->pin || @@ -1113,9 +1141,10 @@ map_grant_ref( =20 if ( !act->pin ) { - unsigned long gfn =3D evaluate_nospec(rgt->gt_version =3D=3D 1= ) ? - shared_entry_v1(rgt, ref).frame : - shared_entry_v2(rgt, ref).full_page.frame; + unsigned long gfn =3D GNTTAB_MAX_VERSION < 2 || + evaluate_nospec(rgt->gt_version =3D=3D 1) + ? shared_entry_v1(rgt, ref).frame + : shared_entry_v2(rgt, ref).full_page.fram= e; =20 rc =3D get_paged_frame(gfn, &mfn, &pg, op->flags & GNTMAP_readonly, rd); @@ -1124,11 +1153,13 @@ map_grant_ref( act_set_gfn(act, _gfn(gfn)); act->domid =3D ld->domain_id; act->mfn =3D mfn; +#if GNTTAB_MAX_VERSION >=3D 2 act->start =3D 0; act->length =3D PAGE_SIZE; act->is_sub_page =3D false; act->src_domid =3D rd->domain_id; act->trans_gref =3D ref; +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ } } =20 @@ -1350,7 +1381,8 @@ map_grant_ref( =20 grant_read_lock(rgt); =20 - if ( unlikely(evaluate_nospec((rgt->gt_version =3D=3D 1) !=3D + if ( GNTTAB_MAX_VERSION >=3D 2 && + unlikely(evaluate_nospec((rgt->gt_version =3D=3D 1) !=3D (status =3D=3D &shah->flags))) ) { /* @@ -1625,7 +1657,7 @@ unmap_common_complete(struct gnttab_unma =20 act =3D active_entry_acquire(rgt, op->ref); =20 - if ( evaluate_nospec(rgt->gt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(rgt->gt_version =3D=3D = 1) ) status =3D &shared_entry_v1(rgt, op->ref).flags; else if ( evaluate_nospec(op->ref < nr_grant_entries(rgt)) ) status =3D &status_entry(rgt, op->ref); @@ -1947,7 +1979,7 @@ gnttab_grow_table(struct domain *d, unsi } =20 /* Status pages - version 2 */ - if ( evaluate_nospec(gt->gt_version > 1) ) + if ( GNTTAB_MAX_VERSION >=3D 2 && evaluate_nospec(gt->gt_version > 1) ) { if ( gnttab_populate_status_frames(d, gt, req_nr_frames) ) goto shared_alloc_failed; @@ -2122,7 +2154,7 @@ gnttab_setup_table( } =20 if ( (op.nr_frames > nr_grant_frames(gt) || - ((gt->gt_version > 1) && + ((GNTTAB_MAX_VERSION >=3D 2) && (gt->gt_version > 1) && (grant_to_status_frames(op.nr_frames) > nr_status_frames(gt))))= && gnttab_grow_table(d, op.nr_frames) ) { @@ -2472,7 +2504,8 @@ gnttab_transfer( grant_read_lock(e->grant_table); act =3D active_entry_acquire(e->grant_table, gop.ref); =20 - if ( unlikely(evaluate_nospec(e->grant_table->gt_version !=3D ver)= ) ) + if ( GNTTAB_MAX_VERSION >=3D 2 && + unlikely(evaluate_nospec(e->grant_table->gt_version !=3D ver)= ) ) { rc =3D -EILSEQ; goto release; @@ -2538,12 +2571,13 @@ release_grant_for_copy( act =3D active_entry_acquire(rgt, gref); mfn =3D act->mfn; =20 - if ( evaluate_nospec(rgt->gt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(rgt->gt_version =3D=3D = 1) ) { status =3D &shared_entry_v1(rgt, gref).flags; td =3D rd; trans_gref =3D gref; } +#if GNTTAB_MAX_VERSION >=3D 2 else { if ( evaluate_nospec(gref < nr_grant_entries(rgt)) ) @@ -2552,6 +2586,7 @@ release_grant_for_copy( ? rd : knownalive_domain_from_domid(act->src_domid); trans_gref =3D act->trans_gref; } +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ =20 if ( readonly ) { @@ -2566,13 +2601,15 @@ release_grant_for_copy( =20 reduce_status_for_pin(rd, act, status, readonly); =20 +#if GNTTAB_MAX_VERSION >=3D 2 if ( !act->pin && act->is_sub_page ) atomic_dec(&rgt->nr_v2_ops); +#endif =20 active_entry_release(act); grant_read_unlock(rgt); =20 - if ( td !=3D rd ) + if ( GNTTAB_MAX_VERSION >=3D 2 && td !=3D rd ) { /* * Recursive call, but it is bounded (acquire permits only a single @@ -2593,8 +2630,11 @@ release_grant_for_copy( static int acquire_grant_for_copy( struct domain *rd, grant_ref_t gref, domid_t ldom, bool readonly, - mfn_t *mfn, struct page_info **page, uint16_t *page_off, - uint16_t *length, bool allow_transitive) + mfn_t *mfn, struct page_info **page +#if GNTTAB_MAX_VERSION >=3D 2 + , uint16_t *page_off, uint16_t *length, bool allow_transitive +#endif + ) { struct grant_table *rgt =3D rd->grant_table; grant_entry_v2_t *sha2; @@ -2637,7 +2677,7 @@ acquire_grant_for_copy( goto unlock_out; } =20 - if ( evaluate_nospec(rgt->gt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(rgt->gt_version =3D=3D = 1) ) { sha2 =3D NULL; status =3D &shah->flags; @@ -2652,6 +2692,7 @@ acquire_grant_for_copy( barrier(); =20 old_pin =3D act->pin; +#if GNTTAB_MAX_VERSION >=3D 2 if ( sha2 && (shflags & GTF_type_mask) =3D=3D GTF_transitive ) { domid_t trans_domid; @@ -2786,8 +2827,10 @@ acquire_grant_for_copy( else atomic_dec(&rgt->nr_v2_ops); } - else if ( !old_pin || - (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask= ))) ) + else +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ + if ( !old_pin || + (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask))) ) { unsigned long gfn; =20 @@ -2828,23 +2871,29 @@ acquire_grant_for_copy( if ( !act->pin ) { act->domid =3D ldom; + act->mfn =3D grant_mfn; + +#if GNTTAB_MAX_VERSION >=3D 2 act->is_sub_page =3D is_sub_page; act->start =3D trans_page_off; act->length =3D trans_length; act->src_domid =3D rd->domain_id; act->trans_gref =3D gref; - act->mfn =3D grant_mfn; =20 if ( is_sub_page ) atomic_inc(&rgt->nr_v2_ops); +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ } else if ( !mfn_eq(act->mfn, grant_mfn) || +#if GNTTAB_MAX_VERSION >=3D 2 act->src_domid !=3D rd->domain_id || act->trans_gref !=3D gref || (act->is_sub_page && (!is_sub_page || act->start !=3D trans_page_off || - act->length !=3D trans_length)) ) + act->length !=3D trans_length)) || +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ + false ) { put_page(*page); *page =3D NULL; @@ -2881,8 +2930,10 @@ acquire_grant_for_copy( =20 act->pin +=3D pin_incr; =20 +#if GNTTAB_MAX_VERSION >=3D 2 *page_off =3D act->start; *length =3D act->length; +#endif *mfn =3D act->mfn; =20 active_entry_release(act); @@ -3014,13 +3065,20 @@ static int gnttab_copy_claim_buf(const s rc =3D acquire_grant_for_copy(buf->domain, ptr->u.ref, current->domain->domain_id, buf->read_only, - &buf->mfn, &buf->page, - &buf->ptr.offset, &buf->len, - opt_transitive_grants); + &buf->mfn, &buf->page +#if GNTTAB_MAX_VERSION >=3D 2 + , &buf->ptr.offset, &buf->len, + opt_transitive_grants +#endif + ); if ( rc !=3D GNTST_okay ) goto out; buf->ptr.u.ref =3D ptr->u.ref; buf->have_grant =3D 1; +#if GNTTAB_MAX_VERSION < 2 + buf->ptr.offset =3D 0; + buf->len =3D PAGE_SIZE; +#endif } else { @@ -3241,6 +3299,12 @@ gnttab_set_version(XEN_GUEST_HANDLE_PARA if ( gt->gt_version =3D=3D op.version ) goto out_unlock; =20 + if ( GNTTAB_MAX_VERSION < 2 ) + { + res =3D -EOPNOTSUPP; + goto out_unlock; + } + /* * Make sure that the grant table isn't currently in use when we * change the version number, except for the first 8 entries which @@ -3270,6 +3334,7 @@ gnttab_set_version(XEN_GUEST_HANDLE_PARA break; =20 case 2: +#if GNTTAB_MAX_VERSION >=3D 2 if ( atomic_read(>->nr_v2_ops) ) { gdprintk(XENLOG_WARNING, @@ -3278,6 +3343,7 @@ gnttab_set_version(XEN_GUEST_HANDLE_PARA res =3D -EAGAIN; goto out_unlock; } +#endif /* GNTTAB_MAX_VERSION >=3D 2 */ =20 for ( i =3D 0; i < GNTTAB_NR_RESERVED_ENTRIES; i++ ) { @@ -3527,7 +3593,7 @@ swap_grant_ref(grant_ref_t ref_a, grant_ goto out; } =20 - if ( evaluate_nospec(gt->gt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(gt->gt_version =3D=3D 1= ) ) { grant_entry_v1_t shared; =20 @@ -3945,7 +4011,7 @@ int gnttab_release_mappings(struct domai =20 act =3D active_entry_acquire(rgt, ref); sha =3D shared_entry_header(rgt, ref); - if ( rgt->gt_version =3D=3D 1 ) + if ( GNTTAB_MAX_VERSION < 2 || rgt->gt_version =3D=3D 1 ) status =3D &sha->flags; else status =3D &status_entry(rgt, ref); @@ -4120,7 +4186,7 @@ int mem_sharing_gref_to_gfn(struct grant rc =3D -EINVAL; else if ( ref >=3D nr_grant_entries(gt) ) rc =3D -ENOENT; - else if ( evaluate_nospec(gt->gt_version =3D=3D 1) ) + else if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(gt->gt_version =3D= =3D 1) ) { const grant_entry_v1_t *sha1 =3D &shared_entry_v1(gt, ref); =20 @@ -4144,7 +4210,7 @@ int mem_sharing_gref_to_gfn(struct grant rc =3D -ENXIO; else if ( !rc && status ) { - if ( evaluate_nospec(gt->gt_version =3D=3D 1) ) + if ( GNTTAB_MAX_VERSION < 2 || evaluate_nospec(gt->gt_version =3D= =3D 1) ) *status =3D flags; else *status =3D status_entry(gt, ref); @@ -4275,7 +4341,7 @@ int gnttab_acquire_resource( break; =20 case XENMEM_resource_grant_table_id_status: - if ( gt->gt_version !=3D 2 ) + if ( GNTTAB_MAX_VERSION < 2 || gt->gt_version !=3D 2 ) break; =20 /* Check that void ** is a suitable representation for gt->status.= */ @@ -4327,7 +4393,8 @@ int gnttab_map_frame_begin( =20 grant_write_lock(gt); =20 - if ( evaluate_nospec(gt->gt_version =3D=3D 2) && (idx & XENMAPIDX_gran= t_table_status) ) + if ( GNTTAB_MAX_VERSION >=3D 2 && evaluate_nospec(gt->gt_version =3D= =3D 2) && + (idx & XENMAPIDX_grant_table_status) ) { idx &=3D ~XENMAPIDX_grant_table_status; rc =3D gnttab_get_status_frame_mfn(d, idx, mfn); @@ -4395,7 +4462,7 @@ static void gnttab_usage_print(struct do =20 sha =3D shared_entry_header(gt, ref); =20 - if ( gt->gt_version =3D=3D 1 ) + if ( GNTTAB_MAX_VERSION < 2 || gt->gt_version =3D=3D 1 ) { status =3D sha->flags; frame =3D shared_entry_v1(gt, ref).frame; --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -39,7 +39,16 @@ void gnttab_seed_entry(const struct doma =20 #ifdef CONFIG_GRANT_TABLE =20 +#ifndef GNTTAB_MAX_VERSION +#define GNTTAB_MAX_VERSION 2 +#endif + +#if GNTTAB_MAX_VERSION >=3D 2 extern unsigned int opt_gnttab_max_version; +#else +# define opt_gnttab_max_version GNTTAB_MAX_VERSION +#endif + extern unsigned int opt_max_grant_frames; =20 /* Create/destroy per-domain grant table context. */