[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM

Gerd Hoffmann posted 1 patch 1 month ago
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Gerd Hoffmann 1 month ago
On Wed, Feb 05, 2025 at 10:53:04AM -0500, Christopher Lentocha wrote:
> Is it already pushed?

Nope, apparently something went wrong ...

> I think I need to add a `if (CONFIG_CSM) {` to it
> 
> because I think it wasn't working with the regual bios.bin without CSM

Does a controller reset (see below) work in both cases?

take care,
  Gerd

commit 79d50d3c156dfd15ed710d0e2313d113251aeb2e
Author: Gerd Hoffmann <kraxel@redhat.com>
Date:   Thu Feb 6 12:10:21 2025 +0100

    ahci: add controller reset

diff --git a/src/hw/ahci.c b/src/hw/ahci.c
index 4f0f640a1c64..2285d33d4ae2 100644
--- a/src/hw/ahci.c
+++ b/src/hw/ahci.c
@@ -637,7 +637,7 @@ static void
 ahci_controller_setup(struct pci_device *pci)
 {
     struct ahci_port_s *port;
-    u32 val, pnr, max;
+    u32 pnr, max;
 
     if (create_bounce_buf() < 0)
         return;
@@ -660,8 +660,8 @@ ahci_controller_setup(struct pci_device *pci)
 
     pci_enable_busmaster(pci);
 
-    val = ahci_ctrl_readl(ctrl, HOST_CTL);
-    ahci_ctrl_writel(ctrl, HOST_CTL, val | HOST_CTL_AHCI_EN);
+    ahci_ctrl_writel(ctrl, HOST_CTL, HOST_CTL_RESET);
+    ahci_ctrl_writel(ctrl, HOST_CTL, HOST_CTL_AHCI_EN);
 
     ctrl->caps = ahci_ctrl_readl(ctrl, HOST_CAP);
     ctrl->ports = ahci_ctrl_readl(ctrl, HOST_PORTS_IMPL);

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Gerd Hoffmann 1 day, 19 hours ago
On Thu, Feb 06, 2025 at 12:14:31PM +0100, Gerd Hoffmann wrote:
> On Wed, Feb 05, 2025 at 10:53:04AM -0500, Christopher Lentocha wrote:
> > Is it already pushed?
> 
> Nope, apparently something went wrong ...
> 
> > I think I need to add a `if (CONFIG_CSM) {` to it
> > 
> > because I think it wasn't working with the regual bios.bin without CSM
> 
> Does a controller reset (see below) work in both cases?
> 
> take care,
>   Gerd
> 
> commit 79d50d3c156dfd15ed710d0e2313d113251aeb2e
> Author: Gerd Hoffmann <kraxel@redhat.com>
> Date:   Thu Feb 6 12:10:21 2025 +0100
> 
>     ahci: add controller reset

Patch pushed now.

take care,
  Gerd

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Christopher Lentocha 1 month ago
Indeed, the patch you provided works for both CSM in QEMU mode and
QEMU's bios.bin mode.

Testing Results (For this whole time, just for reference):

EDK2 Build Revision: e7d7f02c8e157e936855a091948757f78c7d0298
SeaBIOS Build Revision: df9dd418b3b0e586cb208125094620fc7f90f23d
(SeaBIOS with your patch applied from your last message)
QEMU Build Revision: 621da7789083b80d6f1ff1c0fb499334007b4f51

QEMU command line I used is too long, but if you want it anyways, please
do ask!

In short, I used pc-i440fx-7.1 with a Vista Install CD and Vista
installed QCOW2 Image, and switched between the firmware with the -bios
command-line option.

- Christopher Lentocha <christopherericlentocha@gmail.com>

On 2/6/25 6:14 AM, Gerd Hoffmann wrote:
> On Wed, Feb 05, 2025 at 10:53:04AM -0500, Christopher Lentocha wrote:
>> Is it already pushed?
> 
> Nope, apparently something went wrong ...
> 
>> I think I need to add a `if (CONFIG_CSM) {` to it
>>
>> because I think it wasn't working with the regual bios.bin without CSM
> 
> Does a controller reset (see below) work in both cases?
> 
> take care,
>    Gerd
> 
> commit 79d50d3c156dfd15ed710d0e2313d113251aeb2e
> Author: Gerd Hoffmann <kraxel@redhat.com>
> Date:   Thu Feb 6 12:10:21 2025 +0100
> 
>      ahci: add controller reset
> 
> diff --git a/src/hw/ahci.c b/src/hw/ahci.c
> index 4f0f640a1c64..2285d33d4ae2 100644
> --- a/src/hw/ahci.c
> +++ b/src/hw/ahci.c
> @@ -637,7 +637,7 @@ static void
>   ahci_controller_setup(struct pci_device *pci)
>   {
>       struct ahci_port_s *port;
> -    u32 val, pnr, max;
> +    u32 pnr, max;
>   
>       if (create_bounce_buf() < 0)
>           return;
> @@ -660,8 +660,8 @@ ahci_controller_setup(struct pci_device *pci)
>   
>       pci_enable_busmaster(pci);
>   
> -    val = ahci_ctrl_readl(ctrl, HOST_CTL);
> -    ahci_ctrl_writel(ctrl, HOST_CTL, val | HOST_CTL_AHCI_EN);
> +    ahci_ctrl_writel(ctrl, HOST_CTL, HOST_CTL_RESET);
> +    ahci_ctrl_writel(ctrl, HOST_CTL, HOST_CTL_AHCI_EN);
>   
>       ctrl->caps = ahci_ctrl_readl(ctrl, HOST_CAP);
>       ctrl->ports = ahci_ctrl_readl(ctrl, HOST_PORTS_IMPL);
> 
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Gerd Hoffmann 1 month ago
On Thu, Feb 06, 2025 at 07:23:44AM -0500, Christopher Lentocha wrote:
> Indeed, the patch you provided works for both CSM in QEMU mode and
> QEMU's bios.bin mode.
> 
> Testing Results (For this whole time, just for reference):
> 
> EDK2 Build Revision: e7d7f02c8e157e936855a091948757f78c7d0298
> SeaBIOS Build Revision: df9dd418b3b0e586cb208125094620fc7f90f23d
> (SeaBIOS with your patch applied from your last message)
> QEMU Build Revision: 621da7789083b80d6f1ff1c0fb499334007b4f51
> 
> QEMU command line I used is too long, but if you want it anyways, please
> do ask!
> 
> In short, I used pc-i440fx-7.1 with a Vista Install CD and Vista
> installed QCOW2 Image, and switched between the firmware with the -bios
> command-line option.

Then add a sata controller via -device I assume?  Because
'pc-i440fx-7.1' uses ide storage by default.

I've tested (the non-csm case only) using '-M q35' which uses ahci by
default.  More convenient as you can simply use '-hda' and '-cdrom'
switches to add sata disk + cdrom (but could very well be that the vista
image doesn't boot then if installed using '-M pc').

take care,
  Gerd

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Christopher Lentocha 1 month ago
See below for the command I am now using (I changed it to Q35 since the
last message I sent), for EDK2, I used -bios OVMF.fd instead and removed
-bios bios.bin (which is SeaBIOS).

- Christopher Lentocha

qemu-system-x86_64 \

-name debug-threads=on \

-machine 
pc-q35-2.10,usb=off,vmport=off,smm=on,kernel_irqchip=on,dump-guest-core=off 
\

-accel kvm \

-m 8192 \

-overcommit mem-lock=off \

-smp 4,sockets=1,dies=1,cores=2,threads=2 \

-no-user-config \

-nodefaults \

-chardev socket,id=charmonitor,server=on,wait=off \

-mon chardev=charmonitor,id=monitor,mode=control \

-rtc base=localtime,clock=rt \

-global kvm-pit.lost_tick_policy=discard \

-global ICH9-LPC.disable_s3=0 \

-global ICH9-LPC.disable_s4=0 \

-boot menu=on,strict=on \

-device 
"{'driver':'ich9-usb-ehci1','id':'usb','bus':'pcie.0','addr':'0x2'}" \

-device 
"{'driver':'virtio-serial-pci','id':'virtio-serial0','bus':'pcie.0','addr':'0x9'}" 
\

-blockdev 
"{'driver':'file','filename':'Vista.qcow2','node-name':'libvirt-1-storage','auto-read-only':true,'discard':'unmap'}" 
\

-blockdev 
"{'node-name':'libvirt-1-format','read-only':false,'driver':'qcow2','file':'libvirt-1-storage','backing':null}" 
\

-device 
"{'driver':'ide-hd','bus':'ide.0','drive':'libvirt-1-format','id':'sata0-0-0'}" 
\

-netdev user,id=hostnet0 \

-device 
"{'driver':'e1000e','netdev':'hostnet0','id':'net0','bus':'pcie.0','addr':'0x8'}" 
\

-chardev spicevmc,id=charchannel0,name=vdagent \

-device 
"{'driver':'virtserialport','bus':'virtio-serial0.0','nr':1,'chardev':'charchannel0','id':'channel0','name':'com.redhat.spice.0'}" 
\

-chardev spiceport,id=charchannel1,name=org.spice-space.webdav.0 \

-device 
"{'driver':'virtserialport','bus':'virtio-serial0.0','nr':2,'chardev':'charchannel1','id':'channel1','name':'org.spice-space.webdav.0'}" 
\

-device "{'driver':'usb-tablet','id':'input2','bus':'usb.0','port':'1'}" \

-device "{'driver':'usb-kbd','id':'input3','bus':'usb.0','port':'2'}" \

-audiodev "{'id':'audio1','driver':'spice'}" \

-spice port=0,disable-ticketing=on,seamless-migration=on \

-device 
"{'driver':'vmware-svga','id':'video0','vgamem_mb':512,'bus':'pcie.0','addr':'0xf'}" 
\

-device 
"{'driver':'ich9-intel-hda','id':'sound0','bus':'pcie.0','addr':'0xe'}" \

-device 
"{'driver':'hda-duplex','id':'sound0-codec0','bus':'sound0.0','cad':0,'audiodev':'audio1'}" 
\

-machine pcspk-audiodev=audio1 \

-msg timestamp=on \

-display gtk \

-cdrom Vista.iso

-bios bios.bin



On 2/7/25 07:41, Gerd Hoffmann wrote:
> On Thu, Feb 06, 2025 at 07:23:44AM -0500, Christopher Lentocha wrote:
>> Indeed, the patch you provided works for both CSM in QEMU mode and
>> QEMU's bios.bin mode.
>>
>> Testing Results (For this whole time, just for reference):
>>
>> EDK2 Build Revision: e7d7f02c8e157e936855a091948757f78c7d0298
>> SeaBIOS Build Revision: df9dd418b3b0e586cb208125094620fc7f90f23d
>> (SeaBIOS with your patch applied from your last message)
>> QEMU Build Revision: 621da7789083b80d6f1ff1c0fb499334007b4f51
>>
>> QEMU command line I used is too long, but if you want it anyways, please
>> do ask!
>>
>> In short, I used pc-i440fx-7.1 with a Vista Install CD and Vista
>> installed QCOW2 Image, and switched between the firmware with the -bios
>> command-line option.
> 
> Then add a sata controller via -device I assume?  Because
> 'pc-i440fx-7.1' uses ide storage by default.
> 
> I've tested (the non-csm case only) using '-M q35' which uses ahci by
> default.  More convenient as you can simply use '-hda' and '-cdrom'
> switches to add sata disk + cdrom (but could very well be that the vista
> image doesn't boot then if installed using '-M pc').
> 
> take care,
>    Gerd
> 
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org