[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] OvmfPkg/XenPvBlkDxe: Fix memory barrier macro
- To: Anthony Perard <anthony.perard@xxxxxxxxxx>, "devel@xxxxxxxxxxxxxx" <devel@xxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Tue, 19 Jul 2022 14:12:40 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=46eHTGcIXiTxNKzyN+/IF89NYdtrZ4+vu3IkW/DEro4=; b=TQsUsvCn8USGf6KViJ1f19QwzOW8UUMnJLVxq0TwPo33Kh3WTIiFMxpLp+XA6b/+y21ElpU29AzbsX39qB72RpBR3a1pTRcYzKrWxpzmjm7sIHlc1N7+fz6Fq3FrYv+5w/yL3eKizsBczH7Lw7ZcnPYdBMSIGTrVxAypIYfPLNVELQMiSThGhFZrH7QetVvVq21CHMfaCWrhrFGFg0Ld9xL7XcyrRTWycurvEdEDu28pdg9ZOalk9m3wSAyDpC9Hj/A0LBBgq4BeBqBS3Co3J7U4j/kB3Hf+MDMZUszGAQ19PpLTpB8ZxX1mcXMW/5n4Uay1Sa0XXfojGHrB/rtWbg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lTK0i/w5JXIz0NLO9Lq/IJNPgdDTx59MhYiPSXjOfGxGVHFXrHt8iitmHyVS8UVTvw7aX/beyOHn7W6c7Hsp5NSxXcLjGIXC1T20/jwrSYeLnZssnbCeQ2GMPQ9SbV+hTnIHdc8WdxgxAPH0a5INcJTT7eDMaNGdeFGXnUkmdwVUXln59blqW9Hc7SitQeD59bVyInr/xlGKXBW+Euv3oRiPeaDbOiNmDPNI1hgJDGSJgFxcDDDoTThMTu4wS281Z530J9EBM5LCSnSVvAKBsNWcSCT6fLdTJOqbD3zB31mSvd/REHpCKuaDJ3BbdcAARV0gF9vFFeHALmEyAGMk/g==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ard Biesheuvel <ardb+tianocore@xxxxxxxxxx>, Jiewen Yao <jiewen.yao@xxxxxxxxx>, Jordan Justen <jordan.l.justen@xxxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
- Delivery-date: Tue, 19 Jul 2022 14:13:10 +0000
- Ironport-data: A9a23:TWQW36Jh7TkjX2C4FE+RVpQlxSXFcZb7ZxGr2PjKsXjdYENS1jcEm jYaCz+EM/mLNmr2eo92O4W3pEoOuMXcx4VnQFZlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vraP65xZVF/fngbqLmD+LZMTxGSwZhSSMw4TpugOd8iYNz6TSDK1rlV eja/ouOYjdJ5xYuajhOs/3a+Us11BjPkGhwUmIWNKgjUGD2zxH5PLpHTYmtIn3xRJVjH+LSb 44vG5ngows1Vz90Yj+Uuu6Tnn8iG9Y+DiDX4pZiYICwgwAqm8AH+v1T2Mzwy6tgo27hc9hZk L2hvHErIOsjFvWkdO81C3G0H8ziVEHvFXCuzXWX6KSuI0P6n3TE/ql3PGMvFoYi2sVHAmtXq /A1BxckcUXW7w626OrTpuhEoO0GdZOuEKZB/3ZqwHfeEOosRo3FT+PS/9hE0Twsh8dIW/HDe 84ebjkpZxPFC/FNEg5PVNRiw6H11z+mLGMwRFG9/MLb50D6ygBr3aerG93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19cvX5aQTObNSRP5uw/zvngehTMYd228LAu23FQgMyOeJP7dSueVVspj8ys5/0CH8yzYY fABK5r
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYm3bUnP9y0GYoU0uIINVtZTXPCK2FvEeA
- Thread-topic: [PATCH 1/1] OvmfPkg/XenPvBlkDxe: Fix memory barrier macro
On 19/07/2022 14:52, Anthony Perard wrote:
> diff --git a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h
> b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h
> index 350b7bd309c0..67ee1899e9a8 100644
> --- a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h
> +++ b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.h
> @@ -11,8 +11,9 @@
> #define __EFI_XEN_PV_BLK_DXE_H__
>
> #include <Uefi.h>
> +#include "FullMemoryFence.h"
>
> -#define xen_mb() MemoryFence()
> +#define xen_mb() FullMemoryFence()
> #define xen_rmb() MemoryFence()
> #define xen_wmb() MemoryFence()
Ok, so the old MemoryFence() is definitely bogus here.
However, it doesn't need to be an mfence instruction. All that is
needed is smp_mb(), which these days is
asm volatile ( "lock addl $0, -4(%%rsp)" ::: "memory" )
because that has the required read/write ordering properties without the
extra serialising property that mfence has.
Furthermore, ...
>
> diff --git a/OvmfPkg/XenPvBlkDxe/X86GccFullMemoryFence.c
> b/OvmfPkg/XenPvBlkDxe/X86GccFullMemoryFence.c
> new file mode 100644
> index 000000000000..92d107def470
> --- /dev/null
> +++ b/OvmfPkg/XenPvBlkDxe/X86GccFullMemoryFence.c
> @@ -0,0 +1,20 @@
> +/** @file
> + Copyright (C) 2022, Citrix Ltd.
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include "FullMemoryFence.h"
> +
> +//
> +// Like MemoryFence() but prevent stores from been reorded with loads by
> +// the CPU on X64.
> +//
> +VOID
> +EFIAPI
> +FullMemoryFence (
> + VOID
> + )
> +{
> + __asm__ __volatile__ ("mfence":::"memory");
> +}
... stuff like this needs to come from a single core location, and not
opencoded for each driver.
~Andrew
|