Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEV-SNP Cannot boot guest ubuntu:24.04 to install #233

Open
haruki3hhh opened this issue Sep 3, 2024 · 4 comments
Open

SEV-SNP Cannot boot guest ubuntu:24.04 to install #233

haruki3hhh opened this issue Sep 3, 2024 · 4 comments

Comments

@haruki3hhh
Copy link

haruki3hhh commented Sep 3, 2024

Hi,
I try to build the SEV-SNP env in my machine.

In host, I think the env is built successfully:

name@huasheng:~/AMDSEV$ uname -r
6.11.0-rc3-snp-host-85ef1ac03941

name@huasheng:~/AMDSEV$ sudo dmesg | grep -i -e rmp -e sev
[    0.000000] SEV-SNP: RMP table physical range [0x00000000a0900000 - 0x00000000a4efffff]
[   33.059076] ccp 0000:06:00.5: sev enabled
[   33.194974] ccp 0000:06:00.5: SEV firmware update successful
[   33.486157] ccp 0000:06:00.5: SEV API:1.55 build:21
[   33.486167] ccp 0000:06:00.5: SEV-SNP API:1.55 build:21
[   33.498331] kvm_amd: SEV enabled (ASIDs 30 - 1006)
[   33.498335] kvm_amd: SEV-ES enabled (ASIDs 1 - 29)
[   33.498338] kvm_amd: SEV-SNP enabled (ASIDs 1 - 29)

name@huasheng:~/AMDSEV$ cat /sys/module/kvm_amd/parameters/sev
Y
name@huasheng:~/AMDSEV$ cat /sys/module/kvm_amd/parameters/sev_es 
Y
name@huasheng:~/AMDSEV$  cat /sys/module/kvm_amd/parameters/sev_snp 
Y

Then I try follow the steps here:
https://github.com/AMDESE/AMDSEV?tab=readme-ov-file#ubuntu18-prep-vm

./usr/local/bin/qemu-img create -f qcow2 ubuntu-24.04.qcow2 50G
cp ./usr/local/share/qemu/OVMF_VARS.fd OVMF_VARS.fd
./launch-qemu.sh -hda ubuntu-24.04.qcow2 -cdrom ubuntu-24.04.1-live-server-amd64.iso

ubuntu-24.04.1-live-server-amd64.iso I downloaded from: https://releases.ubuntu.com/24.04/
image

But the screen stuck in here:

InstallProtocolInterface: 4006C0C1-FCB3-403E-996D-4A6C8724E06D 7AE72F30
InstallProtocolInterface: 09576E91-6D3F-11D2-8E39-00A0C969723B 7AE72F40
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
CpuDxe: 5-Level Paging = 0
MpInitChangeApLoopCallback() done!
SetUefiImageMemoryAttributes - 0x000000007EAE4000 - 0x0000000000009000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EADD000 - 0x0000000000007000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAD7000 - 0x0000000000006000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAD0000 - 0x0000000000007000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAC0000 - 0x0000000000010000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EABB000 - 0x0000000000005000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAB4000 - 0x0000000000007000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAB0000 - 0x0000000000004000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000007EAAB000 - 0x0000000000005000 (0x0000000000000008)
image

The qemu CMD running is:

/home/name/AMDSEV/usr/local/bin/qemu-system-x86_64 -enable-kvm -cpu EPYC-v4 \
-machine q35 -smp 4,maxcpus=255 -m 2048M,slots=5,maxmem=10240M \
-no-reboot \
-drive if=pflash,format=raw,unit=0,file=/home/name/AMDSEV/usr/local/share/qemu/OVMF_CODE.fd,readonly \
-drive if=pflash,format=raw,unit=1,file=/home/name/AMDSEV/ubuntu-24.04.fd \
-drive file=/home/name/AMDSEV/ubuntu-24.04.1-live-server-amd64.iso,media=cdrom \
-boot d \
-drive file=/home/name/AMDSEV/ubuntu-24.04.qcow2,if=none,id=disk0,format=qcow2 \
-device virtio-scsi-pci,id=scsi0,disable-legacy=on,iommu_platform=true \
-device scsi-hd,drive=disk0 \
-nographic \
-monitor pty \
-monitor unix:monitor,server,nowait

Could you help me about it?

Appreciate!

@ghe0
Copy link

ghe0 commented Oct 15, 2024

I have the same issue with Ubuntu 22.04, and I am just running ./launch-qemu.sh from the snp-latest branch.

@tlendacky
Copy link
Collaborator

Try adding console=ttyS0,115200n8 to the command line of the "Try or Install Ubuntu Server" grub entry.

@haruki3hhh
Copy link
Author

Hi @ghe0

I have solved this problem by following steps for guest VM:

  1. Build the Guest
./usr/local/bin/qemu-img create -f qcow2 ubuntu-24.04.qcow2 50G
cp ./usr/local/share/qemu/OVMF_VARS.fd OVMF_VARS.fd
  1. Then use virt-install
ISO_LOCATION="/media/isos/ubuntu-24.04.1-live-server-amd64.iso"
DISK_LOCATION="/var/kvm/machines/ubuntu-24.04.qcow2"
virt-install \
        --name U2404 \
        --ram 8192 \
        --disk path=$DISK_LOCATION,size=50 \
        --boot loader=/usr/share/OVMF/OVMF_CODE_4M.fd,loader.secure='no',loader.type=pflash,nvram=/var/lib/libvirt/qemu/nvram/U2404.fd \
        --vcpus 2 \
        --os-variant ubuntu24.04 \
        --network bridge=virbr0 --graphics none --console pty,target_type=serial \
        --location $ISO_LOCATION,kernel=casper/vmlinuz,initrd=casper/initrd \
        --extra-args 'console=ttyS0,115200n8'

Which can automatically install the iso, otherwise you will be stuck during the installation process.

When installation is done.

  1. Boot CVM
./launch-qemu.sh -hda ubuntu-24.04.qcow2 -sev-snp

After CVM is launched, you should be able to replace the guest kernel just as what you did for the host kernel.

After updating the guest kernel to sev kernel, all done.

You can also boot CVM by:

/home/ziyi/AMDSEV/usr/local/bin/qemu-system-x86_64 \
        -enable-kvm \
        -cpu EPYC-v4 \
        -machine q35 \
        -smp 4,maxcpus=255 \
        -m 2048M,slots=5,maxmem=10240M \
        -no-reboot \
        -bios /home/ziyi/AMDSEV/usr/local/share/qemu/OVMF.fd \
        -drive file=/var/kvm/machines/ubuntu-24.04.qcow2,if=none,id=disk0,format=qcow2 \
        -device virtio-scsi-pci,id=scsi0,disable-legacy=on,iommu_platform=true \
        -device scsi-hd,drive=disk0 \
        -machine memory-encryption=sev0,vmport=off \
        -object memory-backend-memfd,id=ram1,size=2048M,share=true,prealloc=false\
        -machine memory-backend=ram1 \
        -object sev-snp-guest,id=sev0,policy=0xb0000,cbitpos=51,reduced-phys-bits=1 \
        -nographic \
        -monitor pty \
        -monitor unix:monitor,server,nowait \

@ghe0
Copy link

ghe0 commented Oct 16, 2024

Try adding console=ttyS0,115200n8 to the command line of the "Try or Install Ubuntu Server" grub entry.

This did the trick. Thank you!

@haruki3hhh thank you for the steps. I saw you were also using the console arg. I believe that's what was causing the terminal monitor to get stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants