Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BF40C021A0 for ; Mon, 17 Feb 2025 08:44:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.889818.1298856 (Exim 4.92) (envelope-from ) id 1tjwjw-0002zK-5M; Mon, 17 Feb 2025 08:44:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 889818.1298856; Mon, 17 Feb 2025 08:44:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tjwjw-0002zD-1D; Mon, 17 Feb 2025 08:44:32 +0000 Received: by outflank-mailman (input) for mailman id 889818; Mon, 17 Feb 2025 08:44:31 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tjwjv-0002z7-2n for xen-devel@lists.xenproject.org; Mon, 17 Feb 2025 08:44:31 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 66c5d521-ed0b-11ef-9aa6-95dc52dad729; Mon, 17 Feb 2025 09:44:29 +0100 (CET) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5e050b1491eso1578183a12.0 for ; Mon, 17 Feb 2025 00:44:29 -0800 (PST) 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 a640c23a62f3a-aba53376adcsm853126466b.95.2025.02.17.00.44.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Feb 2025 00:44:28 -0800 (PST) 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" X-Inumbo-ID: 66c5d521-ed0b-11ef-9aa6-95dc52dad729 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1739781869; x=1740386669; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=neVPk9FUD4ptmuHZJgcVmZQwLrVBQ6HtYblOfTwTnpI=; b=TUmdSi9fk/VEKqgDIdo4kAQNxtbN+gr6/xDhdmSenvAkfVMwoAYWJfaFvXdjTfpzzW ebcN6yvcuud4gN4y3ItCiC++wTtt09RyblW44ZEp2/VPR6FJSxz7qcTvXoYvVDmf6b3h JHkIq6jjEuo4fGxx1XzkNXmyZ2I4ECbj8MX6+F4rIAPef440xVmt8kYr08wH0XbHa7gY PDiQ+UIQrgyKCj180q180g1Rx6kjtD/GOWiDKZYTiRepOI1SR4kCFO+gAvsn2HUiceI3 4ZFjTbvOvkM35WP5vvuNeACzgjRV/X4qz7ghjR7CNL2g9mVG8JNvO7YAgTEG47cTpn46 5kvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739781869; x=1740386669; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=neVPk9FUD4ptmuHZJgcVmZQwLrVBQ6HtYblOfTwTnpI=; b=b+d9DsLWlyXHghEjk37R75728xIdHdDHqaB7ugwVJIgBzFzgUrBsSaKMFGWvlIDzNm 4XUMnBSm0LwK8dbk0oE+igSbvdsIj3NvMUsk0UscGn7SpY0CNZdNwvtjqy9M/zFKkLzV fqhwLEAAlSgZseKyILA1UE/zTV0OIWZR0/iFUxHBoZd/u4NDROdkbd9aWhNDJtKJj4zD sxOhekW1/DP8FjkHjAPHm2tI3KUL7rdEsmIzTvJliL+bpzzp0e5256AHVwSRKEJOUZMS XoP+b0JhJ3EEvSe2kKd5YXgpJZRu8tTXmv8xClXgDEJQAXj4MP/7OLNyIlWrwfv5lBfL 1Tvw== X-Forwarded-Encrypted: i=1; AJvYcCVzk3ORI1M9OehtnXUEYg2+ZQLbBlkd3KZW4wqf77NMyfrqNKFE4eH2OrMHHL7AZdUbKgzHLBHqH1U=@lists.xenproject.org X-Gm-Message-State: AOJu0YyHOR2wICCVGeZHhO15Y9yYbk/Zn8UIEcq2pmN6aDa8Secr6lGb 77HUVFxMbTYNx5bF6zR0xdN3cgIwY5PsVVJpQ7G3mUABO1byFXiFp4tuZjNccQ== X-Gm-Gg: ASbGncvwLI1sGSsJzW8Ltj1mDhfFFmfYb6ShOWPHE9Mtqm4fxI3e5rJQurH8iEwOuNG czEdP4F7Q/5jKbFjam9HW/MHhFJbdfi1oeYxq0P8JmnIHOWsyiRgQ7qBrvDQkWWz/cd6Y5Hmny3 uTchvG3hsVXM7ftMmoB0H2rp8T6Gi7bZHV8O/AgScaVBisn+XFe/juLmcRU4jzxdRANpp8lfqCl J13bi283/plrSgpKS+dpFrTh4rhCrjaMEW2ClK1OCd5zTavBDgJ7c43MW2/LEVzJiSbt81R2w9y 4gpzK/KwvowOLsi85O8lJa4w047ZBgsYW6lDwWoafUxjyUMJOeuzt0D8CpXVOxtFEgt5JvhTrM1 l X-Google-Smtp-Source: AGHT+IGygZQLpcNcDcZ1h581aZlHWODV43ZwLuNmBYNbNw91a31CRej6uh4haQdLRHHms+bjsqKsNQ== X-Received: by 2002:a17:906:314f:b0:aba:e1eb:1a90 with SMTP id a640c23a62f3a-abb70410b2fmr808396266b.0.1739781869114; Mon, 17 Feb 2025 00:44:29 -0800 (PST) Message-ID: Date: Mon, 17 Feb 2025 09:44:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] x86/dom0: attempt to fixup p2m page-faults for PVH dom0 To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini , xen-devel@lists.xenproject.org References: <20250214092928.28932-1-roger.pau@citrix.com> <20250214092928.28932-3-roger.pau@citrix.com> Content-Language: en-US From: Jan Beulich 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 17.02.2025 09:25, Roger Pau Monné wrote: > On Fri, Feb 14, 2025 at 02:07:05PM +0100, Jan Beulich wrote: >> On 14.02.2025 13:38, Roger Pau Monné wrote: >>> On Fri, Feb 14, 2025 at 12:53:01PM +0100, Jan Beulich wrote: >>>> On 14.02.2025 10:29, Roger Pau Monne wrote: >>>>> +{ >>>>> + unsigned long gfn = paddr_to_pfn(addr); >>>>> + struct domain *currd = current->domain; >>>>> + p2m_type_t type; >>>>> + mfn_t mfn; >>>>> + int rc; >>>>> + >>>>> + ASSERT(is_hardware_domain(currd)); >>>>> + ASSERT(!altp2m_active(currd)); >>>>> + >>>>> + /* >>>>> + * Fixups are only applied for MMIO holes, and rely on the hardware domain >>>>> + * having identity mappings for non RAM regions (gfn == mfn). >>>>> + */ >>>>> + if ( !iomem_access_permitted(currd, gfn, gfn) || >>>>> + !is_memory_hole(_mfn(gfn), _mfn(gfn)) ) >>>>> + return -EPERM; >>>>> + >>>>> + mfn = get_gfn(currd, gfn, &type); >>>>> + if ( !mfn_eq(mfn, INVALID_MFN) || !p2m_is_hole(type) ) >>>>> + rc = mfn_eq(mfn, _mfn(gfn)) ? 0 : -EEXIST; >>>> >>>> I understand this is to cover the case where two vCPU-s access the same GFN >>>> at about the same time. However, the "success" log message at the call site >>>> being debug-only means we may be silently hiding bugs in release builds, if >>>> e.g. we get here despite the GFN having had an identity mapping already for >>>> ages. >>> >>> Possibly, but what would be your suggestion to fix this? I will think >>> about it, but I can't immediately see a solution that's not simply to >>> make the message printed by the caller to be gprintk() instead of >>> gdprintk() so catch such bugs. Would you agree to that? >> >> My thinking was that it might be best to propagate a distinguishable error >> code (perhaps -EEXIST, with its present use then replaced) out of the function, >> and make the choice of gprintk() vs gdprintk() depend on that. Accompanied by a >> comment explaining things a little. > > I think it would be easier if I just made those gprintk() instead of > gdprintk(), all with severity XENLOG_DEBUG except for the one that > reports the failure of the fixup function that is XENLOG_WARNING. > Would you be OK with that? Hmm. Okay-ish at best. Even if debug+guest-level messages are suppressed by default, I think it wouldn't be nice if many of them might appear in release builds with guest_loglevel=all. What I find difficult is to predict how high the chances are to see any of them (and then possibly multiple times). Jan