All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Roth <michael.roth@amd.com>
To: "NOMURA JUNICHI(野村 淳一)" <junichi.nomura@nec.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>, "bp@suse.de" <bp@suse.de>
Subject: Re: [Regression v5.19-rc1] crash kexec fails to boot the 2nd kernel (Re: [PATCH v12 38/46] x86/sev: Add SEV-SNP feature detection/setup)
Date: Wed, 29 Jun 2022 08:54:41 -0500	[thread overview]
Message-ID: <20220629135441.7w4ptweifvfyw5rc@amd.com> (raw)
In-Reply-To: <OSZPR01MB6953EEF3F8E63330547E031183BB9@OSZPR01MB6953.jpnprd01.prod.outlook.com>

On Wed, Jun 29, 2022 at 07:38:09AM +0000, NOMURA JUNICHI(野村 淳一) wrote:
> From: Michael Roth <michael.roth@amd.com>
> > Thanks for the debug info. I haven't been able to reproduce this on the
> > Milan or Cascade Lake systems I've tried, with kexec -l/-p, and well as
> > with/without -s, so there may be something hardware/environment-specific
> > going on here, so I could really use your help to test possible fixes.
> 
> Sure.  Thank you for trying to reproduce the problem.
> 
> > > Other places that parses setup_data uses early_memremap() before
> > > accessing the data (e.g. parse_setup_data()).  I wonder if the lack of
> > > remapping causes the problem but find_cc_blob is too early in the
> > > boot process for early_memremap to work.
> > 
> > I think this might be the case. Prior to early_memremap() being
> > available, we need to rely on the initialize identity map set up by the
> > decompression kernel. It has some stuff to add mappings for boot_params
> > and whatnot, but I don't see where boot_params->hdr.setup_data is
> > handled.
> > 
> > If you use kexec -s to force kexec_file_load, then the kernel sets it up
> > so that boot_params->hdr.setup_data points to some memory just after
> > boot_params, and boot/compressed uses 2M pages in its identity map, so
> > that generally ends up handling the whole range.
> > 
> > But if you use kexec's default kexec_load functionality, setup_data might
> > be allocated elsewhere, so in that case we might need explicit mapping. I
> > noticed on my systems boot_params->hdr.setup_data seems to generally end
> > up at 0x100000 for some reason, and maybe that addr just happens to
> > get mapped for other reasons so I don't end up hitting the crash.
> > 
> > Could you give it a shot with the kexec -s flag and so if that works?
> 
> Your explanation makes a lot of sense.  I could successfully boot the 2nd
> kernel if "kexec -s" is used.

Thanks for trying these, that's good to know.

> 
> > If so, can you apply the below potential fix, and retry your original
> > reproducer?
> 
> I tried your potential fix but it didn't work...  The symptom was same
> as before.

Sorry, I just noticed I had a typo in that patch which made it a no-op
effectively. Can you give this a shot?

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index 44c350d627c7..b97b81d3697d 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -110,6 +110,7 @@ void kernel_add_identity_map(unsigned long start, unsigned long end)
 void initialize_identity_maps(void *rmode)
 {
        unsigned long cmdline;
+       struct setup_data *sd;

        /* Exclude the encryption mask from __PHYSICAL_MASK */
        physical_mask &= ~sme_me_mask;
@@ -163,6 +164,12 @@ void initialize_identity_maps(void *rmode)
        cmdline = get_cmd_line_ptr();
        kernel_add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE);

+       sd = (struct setup_data *)boot_params->hdr.setup_data;
+       while (sd) {
+               kernel_add_identity_map((unsigned long)sd, (unsigned long)(sd + sizeof(*sd) + sd->len));
+               sd = (struct setup_data *)sd->next;
+       }
+
        sev_prep_identity_maps(top_level_pgt);

        /* Load the new page-table. */

> 
> -- 
> Jun'ichi Nomura, NEC Corporation / NEC Solution Innovators, Ltd.



  parent reply	other threads:[~2022-06-29 13:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  0:44 [Regression v5.19-rc1] crash kexec fails to boot the 2nd kernel (Re: [PATCH v12 38/46] x86/sev: Add SEV-SNP feature detection/setup) NOMURA JUNICHI(野村 淳一)
2022-06-24  9:03 ` Borislav Petkov
2022-06-24 10:14   ` NOMURA JUNICHI(野村 淳一)
2022-06-29  0:41 ` Michael Roth
2022-06-29  7:38   ` NOMURA JUNICHI(野村 淳一)
2022-06-29  8:20     ` Borislav Petkov
2022-06-29 11:06       ` NOMURA JUNICHI(野村 淳一)
2022-06-29 13:52         ` Michael Roth
2022-06-29 15:35           ` Michael Roth
2022-06-29 13:54     ` Michael Roth [this message]
2022-06-30  8:25       ` NOMURA JUNICHI(野村 淳一)
2022-08-16 14:25 ` [Regression v5.19-rc1] kernel fails to boot, no console output " Jeremi Piotrowski
2022-08-16 15:06   ` Michael Roth
2022-08-17  8:40     ` Jeremi Piotrowski
2022-08-22 16:39       ` Michael Roth
2022-09-08  9:35         ` Jeremi Piotrowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220629135441.7w4ptweifvfyw5rc@amd.com \
    --to=michael.roth@amd.com \
    --cc=bp@suse.de \
    --cc=junichi.nomura@nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.