[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Argo: drop meaningless mfn_valid() check
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Mon, 27 Nov 2023 14:55:52 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YfEfqweG28j+L9GdXNulpUMnE4Sak2c/WgbY0hjebtw=; b=hlk9D06xTaTimJU24jqraqIvzERaYS/hHRIcEWgsgvGwqoFr7q7v3/RMLpvwFxlGfaPePVslEVm0ozs/3LpDk6M9OdWvcOSNpiPl6b0jlVlOfxkyYJZnC6SGoE4Pz+fkWQ0bgkXc/wL0tmvvn7qkEBHEzCNCtFR5wZmLnFYTr1F7cZNolMYucz5KdG8GZU33SzPkawMas83S3OHvbdDI2/AGEWtBXDC55dCpR3Yv5T9HKEamFeVPNZ8YVxeBK+aBCgaFNjjRX+OeC+t0S2w4xmrYbknjrRaq8CdJE9OsnFC8XpELdV/YunKiqDgnto2j/qSl61Ek3rfSrLkR8g2q8g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7hfD7Abu8XXXpE8u5KUXUwBWwh9Qovo+D78ct98EwS3Nn+vglsbBYjmYb128NtJEF8Qs1lcbHZZi7h25BMVfhxIhLbKCIQIX3fMiWvy9jTFprc3Z2fh9a+LX9KpqOQ9yzIg3Syh4htDpqFdadZ5dla1HpDv1M/sBn3g9BHwzONKYC0Owvx0AnlitplGX3kKFjHNEwe0681OMQyMElMzKmaCuOAZOyvYn4mS0yqaaGwXedFarwQCycFnEDdiNCiPikQmQSHg7XxK6DWbwTrikR92GG/3YTQqhE7xjVWjzhx/vlJ9C32VYXaGlvuDKvpTLnbwELZgn9SCxZ4RWH+8VA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Autocrypt: addr=jbeulich@xxxxxxxx; 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
- Cc: Christopher Clark <christopher.w.clark@xxxxxxxxx>
- Delivery-date: Mon, 27 Nov 2023 13:56:04 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Holding a valid struct page_info * in hands already means the referenced
MFN is valid; there's no need to check that again. Convert the checking
logic to a switch(), to help keeping the extra (and questionable) x86-
only check in somewhat tidy shape.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Initially I had this (with less code churn) as
#ifdef CONFIG_X86
if ( p2mt == p2m_ram_logdirty )
ret = -EAGAIN;
else
#endif
if ( (p2mt != p2m_ram_rw) ||
!get_page_type(page, PGT_writable_page) )
ret = -EINVAL;
But the "else" placement seemed too ugly to me. Otoh there better
wouldn't be any special casing of log-dirty here (and instead such a
page be converted, perhaps right in check_get_page_from_gfn() when
readonly=false), at which point the odd "else" would go away, and the
if() likely again be preferable over the switch().
--- a/xen/common/argo.c
+++ b/xen/common/argo.c
@@ -1421,15 +1421,24 @@ find_ring_mfn(struct domain *d, gfn_t gf
return ret;
*mfn = page_to_mfn(page);
- if ( !mfn_valid(*mfn) )
- ret = -EINVAL;
+
+ switch ( p2mt )
+ {
+ case p2m_ram_rw:
+ if ( !get_page_and_type(page, d, PGT_writable_page) )
+ ret = -EINVAL;
+ break;
+
#ifdef CONFIG_X86
- else if ( p2mt == p2m_ram_logdirty )
+ case p2m_ram_logdirty:
ret = -EAGAIN;
+ break;
#endif
- else if ( (p2mt != p2m_ram_rw) ||
- !get_page_and_type(page, d, PGT_writable_page) )
+
+ default:
ret = -EINVAL;
+ break;
+ }
put_page(page);
|