Messages in this thread | | | Date | Wed, 6 Sep 2023 16:01:16 -0700 | Subject | Re: [PATCH] x86/sev-es: Do not use copy_from_kernel_nofault in early #VC handler | From | Dave Hansen <> |
| |
On 9/6/23 15:45, Adam Dunlap wrote: > static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt, > - unsigned char *buffer) > + unsigned char *buffer, bool is_early) > { > - return copy_from_kernel_nofault(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE); > + if (is_early) { > + memcpy(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE); > + return 0; > + } else { > + return copy_from_kernel_nofault(buffer, (unsigned char *)ctxt->regs->ip, > + MAX_INSN_SIZE); > + } > }
This isn't the normal way we do these kinds of things.
If we go with this solution, they next guy who tries copy_from_kernel_nofault() will hit the same issue, and start plumbing their own 'is_early' through _their_ little chunk of arch/x86.
Usually, we'll add some gunk in arch/x86/boot/compressed/misc.h to override the troublesome implementation. In this case, it would make a lot of sense to somehow avoid touching boot_cpu_data.x86_virt_bits in the first place.
| |