[PATCH V2 0/3] acpi: Add machine option to disable SPCR table

Li Chen posted 3 patches 6 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1965d621e25.fafa759e911037.825810937022699867@linux.beauty
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Shannon Zhao <shannon.zhaosl@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Sunil V L <sunilvl@ventanamicro.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
There is a newer version of this series
hw/arm/virt-acpi-build.c       |  5 +++-
hw/core/machine.c              | 22 ++++++++++++++++++
hw/loongarch/virt-acpi-build.c |  4 +++-
hw/riscv/virt-acpi-build.c     |  5 +++-
include/hw/boards.h            |  1 +
qemu-options.hx                |  5 ++++
tests/qtest/bios-tables-test.c | 42 ++++++++++++++++++++++++++++++++++
7 files changed, 81 insertions(+), 3 deletions(-)
[PATCH V2 0/3] acpi: Add machine option to disable SPCR table
Posted by Li Chen 6 months, 3 weeks ago
This series introduces a new machine option, spcr=on|off, allowing users
to disable the ACPI SPCR (Serial Port Console Redirection) table.
By default, SPCR is enabled. Disabling it can help ensure that the guest's
console behavior is determined solely by kernel command-line parameters
on arch like arm64, avoiding unintended serial console configurations imposed
 by firmware.

Also add tests on AArch64 and RISC-V virt machines using TCG and UEFI boot.

Changes since v1:
- Add bios-tables-test for RISC-V and ARM as suggested by 
- Add Acked-by from Michael S. Tsirkin for the first patch
- Add Reviewed-by from Bibo Mao for the first patch

Li Chen (3):
  acpi: Add machine option to disable SPCR table as suggested by Philippe Mathieu-Daudé
  tests/qtest/bios-tables-test: Add test for disabling SPCR on AArch64
  tests/qtest/bios-tables-test: Add test for disabling SPCR on RISC-V

 hw/arm/virt-acpi-build.c       |  5 +++-
 hw/core/machine.c              | 22 ++++++++++++++++++
 hw/loongarch/virt-acpi-build.c |  4 +++-
 hw/riscv/virt-acpi-build.c     |  5 +++-
 include/hw/boards.h            |  1 +
 qemu-options.hx                |  5 ++++
 tests/qtest/bios-tables-test.c | 42 ++++++++++++++++++++++++++++++++++
 7 files changed, 81 insertions(+), 3 deletions(-)

-- 
2.49.0
Re: [PATCH V2 0/3] acpi: Add machine option to disable SPCR table
Posted by bibo mao 6 months, 3 weeks ago

On 2025/4/22 下午8:03, Li Chen wrote:
> This series introduces a new machine option, spcr=on|off, allowing users
> to disable the ACPI SPCR (Serial Port Console Redirection) table.
> By default, SPCR is enabled. Disabling it can help ensure that the guest > console behavior is determined solely by kernel command-line parameters
Hi Li,

SPCR only provides serial port HW description information.

However how to use is determined by Linux kernel, Can you describe the 
detailed scenario which is unintended serial console configurations 
imposed by firmware?

Regards
Bibo Mao
> on arch like arm64, avoiding unintended serial console configurations imposed
>   by firmware.
> 
> Also add tests on AArch64 and RISC-V virt machines using TCG and UEFI boot.
> 
> Changes since v1:
> - Add bios-tables-test for RISC-V and ARM as suggested by
> - Add Acked-by from Michael S. Tsirkin for the first patch
> - Add Reviewed-by from Bibo Mao for the first patch
> 
> Li Chen (3):
>    acpi: Add machine option to disable SPCR table as suggested by Philippe Mathieu-Daudé
>    tests/qtest/bios-tables-test: Add test for disabling SPCR on AArch64
>    tests/qtest/bios-tables-test: Add test for disabling SPCR on RISC-V
> 
>   hw/arm/virt-acpi-build.c       |  5 +++-
>   hw/core/machine.c              | 22 ++++++++++++++++++
>   hw/loongarch/virt-acpi-build.c |  4 +++-
>   hw/riscv/virt-acpi-build.c     |  5 +++-
>   include/hw/boards.h            |  1 +
>   qemu-options.hx                |  5 ++++
>   tests/qtest/bios-tables-test.c | 42 ++++++++++++++++++++++++++++++++++
>   7 files changed, 81 insertions(+), 3 deletions(-)
> 


Re: [PATCH V2 0/3] acpi: Add machine option to disable SPCR table
Posted by Li Chen 6 months, 3 weeks ago
Hi Bibo,

 ---- On Wed, 23 Apr 2025 14:27:36 +0800  bibo mao <maobibo@loongson.cn> wrote --- 
 > 
 > 
 > On 2025/4/22 下午8:03, Li Chen wrote:
 > > This series introduces a new machine option, spcr=on|off, allowing users
 > > to disable the ACPI SPCR (Serial Port Console Redirection) table.
 > > By default, SPCR is enabled. Disabling it can help ensure that the guest > console behavior is determined solely by kernel command-line parameters
 > Hi Li,
 > 
 > SPCR only provides serial port HW description information.
 > 
 > However how to use is determined by Linux kernel, Can you describe the 
 > detailed scenario which is unintended serial console configurations 
 > imposed by firmware?

Yes, it is decided by the kernel, more specifically, by how architecture-specific code utilizes acpi_parse_spcr. For example, in the 5.10 arm64 kernel 
https://elixir.bootlin.com/linux/v5.10.236/source/arch/arm64/kernel/acpi.c#L236,  it passes true to acpi_parse_spcr's param enable_console.

So, SPCR consoles are respected by Arm64 Linux by default. Therefore, even without a console=ttyAMA0 configuration, ttyAMA0 is still added as a preferred console
and used by printk.

Regards,
Li
Re: [PATCH V2 0/3] acpi: Add machine option to disable SPCR table
Posted by bibo mao 6 months, 3 weeks ago

On 2025/4/23 下午4:36, Li Chen wrote:
> Hi Bibo,
> 
>   ---- On Wed, 23 Apr 2025 14:27:36 +0800  bibo mao <maobibo@loongson.cn> wrote ---
>   >
>   >
>   > On 2025/4/22 下午8:03, Li Chen wrote:
>   > > This series introduces a new machine option, spcr=on|off, allowing users
>   > > to disable the ACPI SPCR (Serial Port Console Redirection) table.
>   > > By default, SPCR is enabled. Disabling it can help ensure that the guest > console behavior is determined solely by kernel command-line parameters
>   > Hi Li,
>   >
>   > SPCR only provides serial port HW description information.
>   >
>   > However how to use is determined by Linux kernel, Can you describe the
>   > detailed scenario which is unintended serial console configurations
>   > imposed by firmware?
> 
> Yes, it is decided by the kernel, more specifically, by how architecture-specific code utilizes acpi_parse_spcr. For example, in the 5.10 arm64 kernel
> https://elixir.bootlin.com/linux/v5.10.236/source/arch/arm64/kernel/acpi.c#L236,  it passes true to acpi_parse_spcr's param enable_console.
> 
> So, SPCR consoles are respected by Arm64 Linux by default. Therefore, even without a console=ttyAMA0 configuration, ttyAMA0 is still added as a preferred console
> and used by printk.
About serial port, there is ACPI SPCR table and DSDT table. About how to 
use, it is decided by kernel, so I think that it probably kernel usage 
issue.

However I have no opposing view with your patch, adding option 
"spcr=on|off" sounds good.

Regards
Bibo Mao
> 
> Regards,
> Li
> 


Re: [PATCH V2 0/3] acpi: Add machine option to disable SPCR table
Posted by Li Chen 6 months, 3 weeks ago
Hi Bibo,

 ---- On Wed, 23 Apr 2025 16:49:09 +0800  bibo mao <maobibo@loongson.cn> wrote --- 
 > 
 > 
 > On 2025/4/23 下午4:36, Li Chen wrote:
 > > Hi Bibo,
 > > 
 > >   ---- On Wed, 23 Apr 2025 14:27:36 +0800  bibo mao <maobibo@loongson.cn> wrote ---
 > >   >
 > >   >
 > >   > On 2025/4/22 下午8:03, Li Chen wrote:
 > >   > > This series introduces a new machine option, spcr=on|off, allowing users
 > >   > > to disable the ACPI SPCR (Serial Port Console Redirection) table.
 > >   > > By default, SPCR is enabled. Disabling it can help ensure that the guest > console behavior is determined solely by kernel command-line parameters
 > >   > Hi Li,
 > >   >
 > >   > SPCR only provides serial port HW description information.
 > >   >
 > >   > However how to use is determined by Linux kernel, Can you describe the
 > >   > detailed scenario which is unintended serial console configurations
 > >   > imposed by firmware?
 > > 
 > > Yes, it is decided by the kernel, more specifically, by how architecture-specific code utilizes acpi_parse_spcr. For example, in the 5.10 arm64 kernel
 > > https://elixir.bootlin.com/linux/v5.10.236/source/arch/arm64/kernel/acpi.c#L236,  it passes true to acpi_parse_spcr's param enable_console.
 > > 
 > > So, SPCR consoles are respected by Arm64 Linux by default. Therefore, even without a console=ttyAMA0 configuration, ttyAMA0 is still added as a preferred console
 > > and used by printk.
 > About serial port, there is ACPI SPCR table and DSDT table. About how to 
 > use, it is decided by kernel, so I think that it probably kernel usage 
 > issue.
 > 
 > However I have no opposing view with your patch, adding option 
 > "spcr=on|off" sounds good.


Thanks, I totally agree with you. BTW, newer kernels introduce the nospcr command-line argument, allowing users to control if respect SPCR or not:
https://elixir.bootlin.com/linux/v6.15-rc3/source/arch/arm64/kernel/acpi.c#L254

Regards,
Li