[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a2cfad68277cae67791f07646c842672593a8dca.camel@infradead.org>
Date: Thu, 08 Feb 2024 09:26:25 -0800
From: David Woodhouse <dwmw2@...radead.org>
To: paul@....org, Sean Christopherson <seanjc@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>, Shuah Khan
<shuah@...nel.org>, kvm@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v12 11/20] KVM: xen: allow shared_info to be mapped by
fixed HVA
On Thu, 2024-02-08 at 16:51 +0000, Paul Durrant wrote:
> On 08/02/2024 16:48, Sean Christopherson wrote:
> > On Thu, Feb 08, 2024, Paul Durrant wrote:
> > > With the benefit of some sleep, I'm wondering why 0 is a 'ridiculous'
> > > invalid value for a *virtual* address? Surely it's essentially a numerical
> > > cast of the canonically invalid NULL pointer?
> >
> > It's legal to mmap() virtual address '0', albeit not by default:
Well yes, to make dosemu work. But if you attempt to actually *do* that
in C code, the compiler itself doesn't cope...
$ cat foo.c
int foo(int *bar)
{
if (bar)
return 0;
return *bar;
}
$ gcc -O2 -S -o- foo.c
..
foo:
LFB0:
.cfi_startproc
endbr64
testq %rdi, %rdi
je .L4
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
L4:
movl 0, %eax
ud2
.cfi_endproc
LFE0:
.size foo, .-foo
Note the ud2 instead of actually trying to dereference it.
Using anything except NULL as the "no value" value doesn't make sense
to me. It violates the principle of least surprise and would be a
really bad API.
Download attachment "smime.p7s" of type "application/pkcs7-signature" (5965 bytes)
Powered by blists - more mailing lists