linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@lists.ozlabs.org
Cc: eajames@linux.ibm.com, jgg@ziepe.ca, jarkko@kernel.org,
	yangyingliang@huawei.com, linux-integrity@vger.kernel.org,
	peterhuewe@gmx.de
Subject: Re: [PATCH v2 2/2] powerpc/tpm: Reserve SML log when kexec'ing with kexec_file_load()
Date: Sun, 18 Jun 2023 20:26:53 -0400	[thread overview]
Message-ID: <bd7a10c8-a077-1c87-98f4-4c31aed2bf36@linux.ibm.com> (raw)
In-Reply-To: <20230615123703.4028156-2-mpe@ellerman.id.au>



On 6/15/23 08:37, Michael Ellerman wrote:
> The TPM code in prom_init.c creates a small buffer of memory to store
> the TPM's SML (Stored Measurement Log). It's communicated to Linux via
> the linux,sml-base/size device tree properties of the TPM node.
> 
> When kexec'ing that buffer can be overwritten, or when kdump'ing it may
> not be mapped by the second kernel. The latter can lead to a crash when
> booting the second kernel such as:
> 
>    tpm_ibmvtpm 71000003: CRQ initialization completed
>    BUG: Unable to handle kernel data access on read at 0xc00000002ffb0000
>    Faulting instruction address: 0xc0000000200a70e0
>    Oops: Kernel access of bad area, sig: 11 [#1]
>    LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
>    Modules linked in:
>    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc2-00134-g9307ce092f5d #314
>    Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1200 0xf000005 of:SLOF,git-5b4c5a pSeries
>    NIP:  c0000000200a70e0 LR: c0000000203dd5dc CTR: 0000000000000800
>    REGS: c000000024543280 TRAP: 0300   Not tainted  (6.2.0-rc2-00134-g9307ce092f5d)
>    MSR:  8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 24002280  XER: 00000006
>    CFAR: c0000000200a70c8 DAR: c00000002ffb0000 DSISR: 40000000 IRQMASK: 0
>    ...
>    NIP memcpy_power7+0x400/0x7d0
>    LR  kmemdup+0x5c/0x80
>    Call Trace:
>      memcpy_power7+0x274/0x7d0 (unreliable)
>      kmemdup+0x5c/0x80
>      tpm_read_log_of+0xe8/0x1b0
>      tpm_bios_log_setup+0x60/0x210
>      tpm_chip_register+0x134/0x320
>      tpm_ibmvtpm_probe+0x520/0x7d0
>      vio_bus_probe+0x9c/0x460
>      really_probe+0x104/0x420
>      __driver_probe_device+0xb0/0x170
>      driver_probe_device+0x58/0x180
>      __driver_attach+0xd8/0x250
>      bus_for_each_dev+0xb4/0x140
>      driver_attach+0x34/0x50
>      bus_add_driver+0x1e8/0x2d0
>      driver_register+0xb4/0x1c0
>      __vio_register_driver+0x74/0x9c
>      ibmvtpm_module_init+0x34/0x48
>      do_one_initcall+0x80/0x320
>      kernel_init_freeable+0x304/0x3ac
>      kernel_init+0x30/0x1a0
>      ret_from_kernel_thread+0x5c/0x64
> 
> To fix the crash, add the SML region to the usable memory areas for the
> kdump kernel, so that the second kernel will map the region. To avoid
> corruption of the region, add the region to the reserved memory areas,

To me the 2nd paragraph and the one below seem to say that in general it does NOT 'avoid corruption of the region.'


> so that the second kernel does not use the memory for something else.
> 
> Note that when loading a kdump kernel with the regular kexec_load()
> syscall the SML may be overwritten by the kdump kernel, depending on
> where the SML is in memory in relation to the crashkernel region. That
> is a separate problem that is not solved by this patch.
> 
> Fixes: a0458284f062 ("powerpc: Add support code for kexec_file_load()")
> Reported-by: Stefan Berger <stefanb@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

I agree to the code:

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>


  reply	other threads:[~2023-06-19  0:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 12:37 [PATCH v2 1/2] powerpc/tpm: Create linux,sml-base/size as big endian Michael Ellerman
2023-06-15 12:37 ` [PATCH v2 2/2] powerpc/tpm: Reserve SML log when kexec'ing with kexec_file_load() Michael Ellerman
2023-06-19  0:26   ` Stefan Berger [this message]
2023-07-10 21:23 ` [PATCH v2 1/2] powerpc/tpm: Create linux,sml-base/size as big endian Jarkko Sakkinen
2023-07-11 12:47   ` Stefan Berger
2023-07-11 21:54     ` Jarkko Sakkinen
2023-07-12 12:39       ` Michael Ellerman
2023-07-17 13:13         ` Jarkko Sakkinen
2023-07-12 12:34     ` Michael Ellerman

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=bd7a10c8-a077-1c87-98f4-4c31aed2bf36@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=eajames@linux.ibm.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=peterhuewe@gmx.de \
    --cc=yangyingliang@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).