Re: [RFC v2-fix-v2 2/2] x86/tdx: Handle in-kernel MMIO

From: Andi Kleen
Date: Wed Jun 02 2021 - 17:02:06 EST


User-space
access triggers SIGBUS.

Actually it looks like it's implemented below now, so that sentence could be dropped.


+
+ if (user_mode(regs)) {
+ ret = insn_fetch_from_user(regs, buffer);
+ if (!ret)
+ return -EFAULT;
+ if (!insn_decode_from_regs(&insn, regs, buffer, ret))
+ return -EFAULT;
+ } else {
+ ret = copy_from_kernel_nofault(buffer, (void *)regs->ip,
+ MAX_INSN_SIZE);
+ if (ret)
+ return -EFAULT;
+ insn_init(&insn, buffer, MAX_INSN_SIZE, 1);
+ insn_get_length(&insn);
+ }
+