[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200525080226.GB25636@zn.tnic>
Date: Mon, 25 May 2020 10:02:26 +0200
From: Borislav Petkov <bp@...en8.de>
To: Joerg Roedel <joro@...tes.org>
Cc: x86@...nel.org, hpa@...or.com, Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Jiri Slaby <jslaby@...e.cz>,
Dan Williams <dan.j.williams@...el.com>,
Tom Lendacky <thomas.lendacky@....com>,
Juergen Gross <jgross@...e.com>,
Kees Cook <keescook@...omium.org>,
David Rientjes <rientjes@...gle.com>,
Cfir Cohen <cfir@...gle.com>,
Erdem Aktas <erdemaktas@...gle.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mike Stunes <mstunes@...are.com>,
Joerg Roedel <jroedel@...e.de>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v3 51/75] x86/sev-es: Handle MMIO events
On Tue, Apr 28, 2020 at 05:17:01PM +0200, Joerg Roedel wrote:
> +static enum es_result vc_do_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
> + unsigned int bytes, bool read)
> +{
> + u64 exit_code, exit_info_1, exit_info_2;
> + unsigned long ghcb_pa = __pa(ghcb);
> + void __user *ref;
> +
> + ref = insn_get_addr_ref(&ctxt->insn, ctxt->regs);
> + if (ref == (void __user *)-1L)
> + return ES_UNSUPPORTED;
> +
> + exit_code = read ? SVM_VMGEXIT_MMIO_READ : SVM_VMGEXIT_MMIO_WRITE;
> +
> + exit_info_1 = vc_slow_virt_to_phys(ghcb, (unsigned long)ref);
> + exit_info_2 = bytes; /* Can never be greater than 8 */
No trailing comments pls - put them over the line.
> + ghcb->save.sw_scratch = ghcb_pa + offsetof(struct ghcb, shared_buffer);
> +
> + return sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, exit_info_1, exit_info_2);
> +}
> +
> +static enum es_result vc_handle_mmio_twobyte_ops(struct ghcb *ghcb,
> + struct es_em_ctxt *ctxt)
> +{
> + struct insn *insn = &ctxt->insn;
> + unsigned int bytes = 0;
> + enum es_result ret;
> + int sign_byte;
> + long *reg_data;
> +
> + switch (insn->opcode.bytes[1]) {
> + /* MMIO Read w/ zero-extension */
> + case 0xb6:
> + bytes = 1;
> + /* Fallthrough */
I'm guessing we're supposed to annotate it this way now:
WARNING: Prefer 'fallthrough;' over fallthrough comment
#139: FILE: arch/x86/kernel/sev-es.c:504:
+ /* Fallthrough */
> + case 0xb7:
> + if (!bytes)
> + bytes = 2;
> +
> + ret = vc_do_mmio(ghcb, ctxt, bytes, true);
> + if (ret)
> + break;
> +
> + /* Zero extend based on operand size */
> + reg_data = vc_insn_get_reg(ctxt);
That function can return NULL - you need to test reg_data. Ditto for all
its invocations.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists