[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86: only modify setup_data if the boot protocol indicates s
From: |
Jason A. Donenfeld |
Subject: |
Re: [PATCH] x86: only modify setup_data if the boot protocol indicates safety |
Date: |
Tue, 6 Sep 2022 12:27:25 +0200 |
Hi Gerd,
On Mon, Sep 5, 2022 at 10:40 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Sun, Sep 04, 2022 at 06:50:58PM +0200, Jason A. Donenfeld wrote:
> > This reverts 3824e25db1 ("x86: disable rng seeding via setup_data"), and
> > then makes the use of setup_data safe. It does so by checking the boot
> > protocol version. If it's sufficient, then it means EFI boots won't
> > crash. While we're at it, gate this on SEV too.
>
> > @@ -463,6 +462,7 @@ static void pc_i440fx_7_0_machine_options(MachineClass
> > *m)
>
> > + pcmc->legacy_no_rng_seed = true;
>
> This needs go into the pc_i440fx_7_1_machine_options function, otherwise
> legacy_no_rng_seed gets flipped from false to true for 7.1 machine types
> which breaks compatibility.
>
> > @@ -398,6 +397,7 @@ static void pc_q35_7_0_machine_options(MachineClass *m)
>
> > + pcmc->legacy_no_rng_seed = true;
>
> Same here.
Oh. Okay so a "straight" revert won't do the trick, since this is (I
guess?) intended for 7.2 rather than 7.1. Makes sense; will do for v2.
>
> > --- a/hw/i386/x86.c
> > +++ b/hw/i386/x86.c
> > @@ -1088,8 +1088,15 @@ void x86_load_linux(X86MachineState *x86ms,
> > qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
> > }
> >
> > - /* Offset 0x250 is a pointer to the first setup_data link. */
> > - stq_p(header + 0x250, first_setup_data);
> > + /*
> > + * Only modify the header if doing so won't crash EFI boot, which is
> > the
> > + * case only for newer boot protocols, and don't do so either if SEV is
> > + * enabled.
> > + */
> > + if (protocol >= 0x210 && !sev_enabled()) {
> > + /* Offset 0x250 is a pointer to the first setup_data link. */
> > + stq_p(header + 0x250, first_setup_data);
> > + }
>
> This should better go into a separate patch.
Alright.
Jason