qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] f9e2b9: linux-user: Emulate /proc/cpuinfo out


From: Richard Henderson
Subject: [Qemu-commits] [qemu/qemu] f9e2b9: linux-user: Emulate /proc/cpuinfo output for riscv
Date: Mon, 15 May 2023 05:32:49 -0700

  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: f9e2b99a44183d1e9abb65354fa5beb2243fded4
      
https://github.com/qemu/qemu/commit/f9e2b99a44183d1e9abb65354fa5beb2243fded4
  Author: Afonso Bordado <afonsobordado@gmail.com>
  Date:   2023-05-01 (Mon, 01 May 2023)

  Changed paths:
    M linux-user/syscall.c
    M tests/tcg/riscv64/Makefile.target
    A tests/tcg/riscv64/cpuinfo.c

  Log Message:
  -----------
  linux-user: Emulate /proc/cpuinfo output for riscv

RISC-V does not expose all extensions via hwcaps, thus some userspace
applications may want to query these via /proc/cpuinfo.

Currently when querying this file the host's file is shown instead
which is slightly confusing. Emulate a basic /proc/cpuinfo file
with mmu info and an ISA string.

Signed-off-by: Afonso Bordado <afonsobordado@gmail.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-Id: <167873059442.9885.15152085316575248452-0@git.sr.ht>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: bf676057e13430bfbc64d485e6a21672bd8f8992
      
https://github.com/qemu/qemu/commit/bf676057e13430bfbc64d485e6a21672bd8f8992
  Author: Thomas Weißschuh <thomas@t-8ch.de>
  Date:   2023-05-01 (Mon, 01 May 2023)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: report ENOTTY for unknown ioctls

The correct error number for unknown ioctls is ENOTTY.

ENOSYS would mean that the ioctl() syscall itself is not implemented,
which is very improbable and unexpected for userspace.

ENOTTY means "Inappropriate ioctl for device". This is what the kernel
returns on unknown ioctls, what qemu is trying to express and what
userspace is prepared to handle.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230426070659.80649-1-thomas@t-8ch.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: d37257d78abf5e16a966115c3ed0e307f9f05ec4
      
https://github.com/qemu/qemu/commit/d37257d78abf5e16a966115c3ed0e307f9f05ec4
  Author: Thomas Weißschuh <thomas@t-8ch.de>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: Add move_mount() syscall

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
[lv: define syscall]
Message-Id: <20230424153429.276788-1-thomas@t-8ch.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 6c5b17f3db864237aac9369980dfc7e9baf1001c
      
https://github.com/qemu/qemu/commit/6c5b17f3db864237aac9369980dfc7e9baf1001c
  Author: Thomas Weißschuh <thomas@t-8ch.de>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: Add open_tree() syscall

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230424153429.276788-2-thomas@t-8ch.de>
[lv: move declaration at the beginning of the block,
     define syscall]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 12896d92f326357756f54286c0f5866503969166
      
https://github.com/qemu/qemu/commit/12896d92f326357756f54286c0f5866503969166
  Author: Thomas Huth <thuth@redhat.com>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/main.c

  Log Message:
  -----------
  linux-user/main: Use list_cpus() instead of cpu_list()

This way we can get rid of the if'deffery and the XXX comment
here (it's repeated in the list_cpus() function anyway).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230424122126.236586-1-thuth@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 69f9f14cda1afbb57c05a0767de870ef2fba0f45
      
https://github.com/qemu/qemu/commit/69f9f14cda1afbb57c05a0767de870ef2fba0f45
  Author: Thomas Weißschuh <thomas@t-8ch.de>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/qemu.h

  Log Message:
  -----------
  linux-user: Add new flag VERIFY_NONE

This can be used to validate that an address range is mapped but without
being readable or writable.

It will be used by an updated implementation of mincore().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230422100314.1650-2-thomas@t-8ch.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 1690bf47cb2fd67b274e15c07cf086e8477feac9
      
https://github.com/qemu/qemu/commit/1690bf47cb2fd67b274e15c07cf086e8477feac9
  Author: Thomas Weißschuh <thomas@t-8ch.de>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: Don't require PROT_READ for mincore

The kernel does not require PROT_READ for addresses passed to mincore.
For example the fincore(1) tool from util-linux uses PROT_NONE and
currently does not work under qemu-user.

Example (with fincore(1) from util-linux 2.38):

$ fincore /proc/self/exe
RES PAGES  SIZE FILE
24K     6 22.1K /proc/self/exe

$ qemu-x86_64 /usr/bin/fincore /proc/self/exe
fincore: failed to do mincore: /proc/self/exe: Cannot allocate memory

With this patch:

$ ./build/qemu-x86_64 /usr/bin/fincore /proc/self/exe
RES PAGES  SIZE FILE
24K     6 22.1K /proc/self/exe

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230422100314.1650-3-thomas@t-8ch.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: cd93f9d0e2bf72ff0a0a89d2641c8bc1b4135c64
      
https://github.com/qemu/qemu/commit/cd93f9d0e2bf72ff0a0a89d2641c8bc1b4135c64
  Author: Daniil Kovalev <dkovalev@compiler-toolchain-for.me>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/mips/cpu_loop.c

  Log Message:
  -----------
  linux-user: Fix mips fp64 executables loading

If a program requires fr1, we should set the FR bit of CP0 control status
register and add F64 hardware flag. The corresponding `else if` branch
statement is copied from the linux kernel sources (see `arch_check_elf` function
in linux/arch/mips/kernel/elf.c).

Signed-off-by: Daniil Kovalev <dkovalev@compiler-toolchain-for.me>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-Id: <20230404052153.16617-1-dkovalev@compiler-toolchain-for.me>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 015ebc4aaa47612514a5c846b9db0d76b653b75f
      
https://github.com/qemu/qemu/commit/015ebc4aaa47612514a5c846b9db0d76b653b75f
  Author: Michael Tokarev <mjt@tls.msk.ru>
  Date:   2023-05-14 (Sun, 14 May 2023)

  Changed paths:
    M linux-user/syscall.c

  Log Message:
  -----------
  linux-user: fix getgroups/setgroups allocations

linux-user getgroups(), setgroups(), getgroups32() and setgroups32()
used alloca() to allocate grouplist arrays, with unchecked gidsetsize
coming from the "guest".  With NGROUPS_MAX being 65536 (linux, and it
is common for an application to allocate NGROUPS_MAX for getgroups()),
this means a typical allocation is half the megabyte on the stack.
Which just overflows stack, which leads to immediate SIGSEGV in actual
system getgroups() implementation.

An example of such issue is aptitude, eg
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811087#72

Cap gidsetsize to NGROUPS_MAX (return EINVAL if it is larger than that),
and use heap allocation for grouplist instead of alloca().  While at it,
fix coding style and make all 4 implementations identical.

Try to not impose random limits - for example, allow gidsetsize to be
negative for getgroups() - just do not allocate negative-sized grouplist
in this case but still do actual getgroups() call.  But do not allow
negative gidsetsize for setgroups() since its argument is unsigned.

Capping by NGROUPS_MAX seems a bit arbitrary, - we can do more, it is
not an error if set size will be NGROUPS_MAX+1. But we should not allow
integer overflow for the array being allocated. Maybe it is enough to
just call g_try_new() and return ENOMEM if it fails.

Maybe there's also no need to convert setgroups() since this one is
usually smaller and known beforehand (KERN_NGROUPS_MAX is actually 63, -
this is apparently a kernel-imposed limit for runtime group set).

The patch fixes aptitude segfault mentioned above.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20230409105327.1273372-1-mjt@msgid.tls.msk.ru>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>


  Commit: 67de9ebd07774e8a78273a23d671b76287dcdbe8
      
https://github.com/qemu/qemu/commit/67de9ebd07774e8a78273a23d671b76287dcdbe8
  Author: Richard Henderson <richard.henderson@linaro.org>
  Date:   2023-05-15 (Mon, 15 May 2023)

  Changed paths:
    M linux-user/main.c
    M linux-user/mips/cpu_loop.c
    M linux-user/qemu.h
    M linux-user/syscall.c
    M tests/tcg/riscv64/Makefile.target
    A tests/tcg/riscv64/cpuinfo.c

  Log Message:
  -----------
  Merge tag 'linux-user-for-8.1-pull-request' of https://github.com/vivier/qemu 
into staging

linux-user pull request 20230512-v2

add open_tree(), move_mount()
add /proc/cpuinfo for riscv
fixes and cleanup

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmRh7bsSHGxhdXJlbnRA
# dml2aWVyLmV1AAoJEPMMOL0/L748EBMP/jX55NLMxEjnWMDVmK0dRBAjpN51ZBl3
# vWwsNp1XVW2GmSqBwAxAyOf4YxbqYjZzep1+SDVMoFm6JiTDBzgvyeeiVJ2wJ7HS
# HIyWSSIJ+IQbvjINl6W4kk1CwehnMoDJ1Uaj1SPkLYgeqtR+RxqQkCmk+sOuEKK3
# R5gVynj6bajWTCYrJMyxsG/P/2z5yfiZ3mhQXqprqHvcEU5LaTvoYZV6pF9iDgCa
# JE21Y6Vr/do5BnoK5Pr39taE5INM8dAsBCwuFg8tNhtTuxw4gj3bnzyZex3NCDDA
# dep6wS9QeOchhpY7YgL22WtQPE5HkwIqIHc8qcNJa41Zmv0o9CPX047ee3juF3+j
# G7Mmmih85QEpA7U8pncP+HcAweRYojS5IeBpqaPr8RRwmJRyQFu8EHyjsYaZ+msQ
# aSY/6j5B+F8nXyrxEOT1T3p4b4eCInsxrC1JA+d5ThDZN4mKl5LBLQEic1cJarJW
# 71m2cSSTN48besI9AJMJp4YOcpyZv5l20q+Hmp304BuIAM4Zn2HmxO2vxubpEjXT
# jRitrK+1nfbmdNXYPGSnHw9k9SEonQgR+Q0gU5/W/Lbwte8n/oxiwE/9Bqy8D+ys
# HmZD1m9fUCbBTQOp8SXdXYPky0QKlL6BdkExaCxGdfgq7GwxyvBlU9CgFgEXceZq
# Pnocsi3jw6AW
# =ctJG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 15 May 2023 01:30:51 AM PDT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [undefined]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [undefined]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" 
[undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* tag 'linux-user-for-8.1-pull-request' of https://github.com/vivier/qemu:
  linux-user: fix getgroups/setgroups allocations
  linux-user: Fix mips fp64 executables loading
  linux-user: Don't require PROT_READ for mincore
  linux-user: Add new flag VERIFY_NONE
  linux-user/main: Use list_cpus() instead of cpu_list()
  linux-user: Add open_tree() syscall
  linux-user: Add move_mount() syscall
  linux-user: report ENOTTY for unknown ioctls
  linux-user: Emulate /proc/cpuinfo output for riscv

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Compare: https://github.com/qemu/qemu/compare/8844bb8d8965...67de9ebd0777



reply via email to

[Prev in Thread] Current Thread [Next in Thread]