linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Tom Lendacky <thomas.lendacky@amd.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>, Vlastimil Babka <vbabka@suse.cz>,
	Mel Gorman <mgorman@techsingularity.net>,
	"Kalra, Ashish" <ashish.kalra@amd.com>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	linux-mm@kvack.org, linux-coco@lists.linux.dev,
	linux-kernel@vger.kernel.org, Michael Roth <michael.roth@amd.com>
Subject: Re: SNP guest crash in memblock with unaccepted memory
Date: Mon, 28 Apr 2025 16:04:50 +0200	[thread overview]
Message-ID: <b037ffeb-bfeb-41a6-b200-d8c57076370f@redhat.com> (raw)
In-Reply-To: <f12f5bd0-135b-91fd-9703-7df98500f9c5@amd.com>

On 27.04.25 17:01, Tom Lendacky wrote:
> Hi Kirill,
> 
> Every now and then I experience an SNP guest boot failure for accessing
> memory that hasn't been accepted. I managed to get a back trace:
> 
>    RIP: 0010:memcpy_orig+0x68/0x130
>    Code: ...
>    RSP: 0000:ffffffff9cc03ce8 EFLAGS: 00010006
>    RAX: ff11001ff83e5000 RBX: 0000000000000000 RCX: fffffffffffff000
>    RDX: 0000000000000bc0 RSI: ffffffff9dba8860 RDI: ff11001ff83e5c00
>    RBP: 0000000000002000 R08: 0000000000000000 R09: 0000000000002000
>    R10: 000000207fffe000 R11: 0000040000000000 R12: ffffffff9d06ef78
>    R13: ff11001ff83e5000 R14: ffffffff9dba7c60 R15: 0000000000000c00
>    memblock_double_array+0xff/0x310
>    memblock_add_range+0x1fb/0x2f0
>    memblock_reserve+0x4f/0xa0
>    memblock_alloc_range_nid+0xac/0x130
>    memblock_alloc_internal+0x53/0xc0
>    memblock_alloc_try_nid+0x3d/0xa0
>    swiotlb_init_remap+0x149/0x2f0
>    mem_init+0xb/0xb0
>    mm_core_init+0x8f/0x350
>    start_kernel+0x17e/0x5d0
>    x86_64_start_reservations+0x14/0x30
>    x86_64_start_kernel+0x92/0xa0
>    secondary_startup_64_no_verify+0x194/0x19b
> 
> I don't know a lot about memblock, but it appears that it needs to
> allocate more memory for it's regions array and returns a range of memory
> that hasn't been accepted. When the memcpy() runs, the SNP guest gets a
> #VC 0x404 because of this.
> 
> Do you think it is as simple as calling accept_memory() on the memory
> range returned from memblock_find_in_range() in memblock_double_array()?

(not Kirill, but replying :) )

Yeah, we seem to be effectively allocating memory from memblock ("from 
ourselves") without considering that memory must be accepted first.

accept_memory() on the new memory (in case of !slab) should be the right 
thing to do.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-04-28 14:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27 15:01 Tom Lendacky
2025-04-28 14:04 ` David Hildenbrand [this message]
2025-04-28 18:10   ` Tom Lendacky
2025-04-28 21:00     ` David Hildenbrand
2025-04-29  7:46       ` Mike Rapoport
2025-04-29  7:33     ` Mike Rapoport
2025-04-30  9:14   ` Kirill A. Shutemov
2025-04-30 14:39     ` Mike Rapoport

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=b037ffeb-bfeb-41a6-b200-d8c57076370f@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ashish.kalra@amd.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=michael.roth@amd.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rppt@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=vbabka@suse.cz \
    /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