NetBSD Problem Report #57813

From www@netbsd.org  Wed Jan  3 09:10:02 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E58E11A9238
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  3 Jan 2024 09:10:01 +0000 (UTC)
Message-Id: <20240103091000.1AC0B1A923A@mollari.NetBSD.org>
Date: Wed,  3 Jan 2024 09:10:00 +0000 (UTC)
From: imil@home.imil.net
Reply-To: imil@home.imil.net
To: gnats-bugs@NetBSD.org
Subject: Support for non-Xen PVH boot on amd64
X-Send-Pr-Version: www-1.0

>Number:         57813
>Category:       kern
>Synopsis:       Support for non-Xen PVH boot on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 03 09:15:00 +0000 2024
>Originator:     Emile 'iMil' Heitor
>Release:        current
>Organization:
NetBSD
>Environment:
NetBSD netbsd 10.99.10 NetBSD 10.99.10 (MICROVM) #811: Wed Jan  3 09:30:48 CET 2024  imil@tatooine:/
home/imil/src/github.com/NetBSD-src/sys/arch/amd64/compile/obj/MICROVM amd64
>Description:
PVH mode, introduced by Xen in version 4.4, permits to boot and pass informations to a kernel using a structure named start_info instead of going through the typical boot process involving the BIOS and a bootloader, which makes PVH boot much faster.

PVH specification which can be read here https://xenbits.xen.org/docs/4.6-testing/misc/pvh.html
NetBSD/Xen is able to boot using the PVH boot mechanism, but can't boot using other hypervisors such as qemu or Firecracker which now support PVH booting.

This is due to the fact that locore.S/start_xen32 expects start_info being passed by the calling hypervisor on %ebx to be located at the end of the symbol table. Qemu and Firecracker don't follow this rule which is not part of the official Xen ABI.
The following patch makes memory mapping loops happy by copying the start_info structure where it's expected.
After that, memory locations and boot parameters are correctly found and
boot can proceed.
Of course, the hypervisor not being Xen, a lot of Xen-related code is
useless, hence the new VM_GUEST_GENPVH (for Generic PVH) vm_guest type.

What's been tested:

- PVH boot with qemu
- PVH boot with Firecracker
- Regular boot with qemu
- Standard Xen domU boot
>How-To-Repeat:
N/A
>Fix:
Apply this patch to NetBSD-current, tested until 10.99.10 https://imil.net/NetBSD/GENPVH.patch

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.