Sergey Bugaev, le mar. 28 févr. 2023 09:39:40 +0300, a ecrit: > > + : \ > > + : "c" (regaddr), "a" (low), "d" (high) \ > > + : "memory" \ > > + ); > > +} > > Why "memory" here? Can wrmsr clobber unrelated memory?
No, but if you don't put a memory clobber here, the compiler will optimize the asm away since it's not said to have side effect. Put another way, the MSR register is some kind of memory. > > +static inline uint64_t rdmsr(uint32_t regaddr) > > +{ > > + uint32_t low, high; > > + asm volatile("rdmsr\n" \ > > + : "=a" (low), "=d" (high) \ > > + : "c" (regaddr) \ > > + ); > > + return ((uint64_t)high << 32) | low; > > Ditto about spacing -- and does this need volatile? As in, does > reading from a MSR have side effects that we're interested in, IIRC it does? > > diff --git a/i386/include/mach/i386/syscall_sw.h > > b/i386/include/mach/i386/syscall_sw.h > > index 86f6ff2f..20ef7c13 100644 > > --- a/i386/include/mach/i386/syscall_sw.h > > +++ b/i386/include/mach/i386/syscall_sw.h > > OK, so the x86_64 syscall definition stays in i386/syscall_sw.h, and > not in a separate x86_64/syscall_sw.h file? That's what I thought. In > this case, we do want that mach-machine patch in glibc. Samuel, does > this make sense to you? Better separate them indeed. > Predicating on USER32 is not really going to work here. Partly because of that :) > it has its own syscall impl, so I need to understand the ABI. > trap_number is in rax, args on the stack, return value in rax, is that > right? What's rcx/r10? Does a syscall preserve other registers? What > about rflags? Is this the same as Linux does or?.. It's the same as Linux. Samuel