Re: [PATCH v1 1/4] x86/tdx: Split MMIO read and write operations

From: Thomas Gleixner
Date: Tue Jul 30 2024 - 14:31:27 EST


On Tue, Jul 30 2024 at 19:35, Alexey Gladkov wrote:
> To implement MMIO in userspace, additional memory checks need to be
> implemented. To avoid overly complicating the handle_mmio() function
> and to separate checks from actions, it will be split into two separate
> functions for handling read and write operations.

It will be split? The patch splits it, no?
>
> +static int handle_mmio_write(struct insn *insn, enum insn_mmio_type mmio, int size,
> + struct pt_regs *regs, struct ve_info *ve)

Please align the second line argument with the first argument in the
first line.

> +static int handle_mmio_read(struct insn *insn, enum insn_mmio_type mmio, int size,
> + struct pt_regs *regs, struct ve_info *ve)
> +{
> + unsigned long *reg, val;
> + int extend_size;
> + u8 extend_val = 0;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

> static int handle_mmio(struct pt_regs *regs, struct ve_info *ve)
> {
> - unsigned long *reg, val, vaddr;
> + unsigned long vaddr;
> char buffer[MAX_INSN_SIZE];
> enum insn_mmio_type mmio;
> struct insn insn = {};
> - int size, extend_size;
> - u8 extend_val = 0;
> + int size;

Ditto

> /* Only in-kernel MMIO is supported */
> if (WARN_ON_ONCE(user_mode(regs)))
> @@ -428,12 +504,6 @@ static int handle_mmio(struct pt_regs *regs, struct ve_info *ve)
> if (WARN_ON_ONCE(mmio == INSN_MMIO_DECODE_FAILED))
> return -EINVAL;

Thanks,

tglx