qemu.git
8 months agotarget/ppc: Unexport some functions from mmu-book3s-v3.h
BALATON Zoltan [Sun, 26 May 2024 23:13:06 +0000 (01:13 +0200)]
target/ppc: Unexport some functions from mmu-book3s-v3.h

The ppc_hash64_hpt_base() and ppc_hash64_hpt_mask() functions are
mostly used by mmu-hash64.c only but there is one call to
ppc_hash64_hpt_mask() in hw/ppc/spapr_vhyp_mmu.c.in a helper function
that can be moved to mmu-hash64.c which allows these functions to be
removed from the header.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu-hash32.c: Move get_pteg_offset32() to the header
BALATON Zoltan [Sun, 26 May 2024 23:13:05 +0000 (01:13 +0200)]
target/ppc/mmu-hash32.c: Move get_pteg_offset32() to the header

This function is a simple shared function, move it to other similar
static inline functions in the header.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_raddr()
BALATON Zoltan [Sun, 26 May 2024 23:13:04 +0000 (01:13 +0200)]
target/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_raddr()

This function is used only once and does not add more clarity than
doing it inline.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:13:03 +0000 (01:13 +0200)]
target/ppc/mmu_common.c: Remove mmu_ctx_t

Completely get rid of mmu_ctx_t after converting the remaining
functions to pass raddr and prot without the context struct.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Stop using ctx in get_bat_6xx_tlb()
BALATON Zoltan [Sun, 26 May 2024 23:13:02 +0000 (01:13 +0200)]
target/ppc/mmu_common.c: Stop using ctx in get_bat_6xx_tlb()

Pass raddr and prot in function parameters instead

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Remove bat_size_prot()
BALATON Zoltan [Sun, 26 May 2024 23:13:01 +0000 (01:13 +0200)]
target/ppc: Remove bat_size_prot()

There is already a hash32_bat_prot() function that does most if this
and the rest can be inlined. Export hash32_bat_prot() and rename it to
ppc_hash32_bat_prot() to match other functions and use it in
get_bat_6xx_tlb().

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Use defines instead of numeric constants
BALATON Zoltan [Sun, 26 May 2024 23:13:00 +0000 (01:13 +0200)]
target/ppc/mmu_common.c: Use defines instead of numeric constants

Replace some BAT related constants with defines from mmu-hash32.h

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Rename function parameter
BALATON Zoltan [Sun, 26 May 2024 23:12:59 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Rename function parameter

Rename parameter of get_bat_6xx_tlb() from virtual to eaddr to match
other functions.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Stop using ctx in ppc6xx_tlb_check()
BALATON Zoltan [Sun, 26 May 2024 23:12:58 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Stop using ctx in ppc6xx_tlb_check()

Pass raddr and prot in function parameters instead.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove key field from mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:12:57 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove key field from mmu_ctx_t

Pass it as a function parameter and remove it from mmu_ctx_t.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Init variable in function that relies on it
BALATON Zoltan [Sun, 26 May 2024 23:12:56 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Init variable in function that relies on it

The ppc6xx_tlb_check() relies on the caller to initialise raddr field
in ctx. Move this init from the only caller into the function.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_prot()
BALATON Zoltan [Sun, 26 May 2024 23:12:55 +0000 (01:12 +0200)]
target/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_prot()

This is used only once and can be inlined.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Add function to get protection key for hash32 MMU
BALATON Zoltan [Sun, 26 May 2024 23:12:54 +0000 (01:12 +0200)]
target/ppc: Add function to get protection key for hash32 MMU

Add a function to get key bit from SR and use it instead of open coded
version.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove ptem field from mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:12:53 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove ptem field from mmu_ctx_t

Instead of passing around ptem in context use it once in the same
function so it can be removed from mmu_ctx_t.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Inline and remove ppc6xx_tlb_pte_check()
BALATON Zoltan [Sun, 26 May 2024 23:12:51 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Inline and remove ppc6xx_tlb_pte_check()

This function is only called once and we can make the caller simpler
by inlining it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Simplify a switch statement
BALATON Zoltan [Sun, 26 May 2024 23:12:50 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Simplify a switch statement

In mmu6xx_get_physical_address() the switch handles all cases so the
default is never reached and can be dropped. Also group together cases
which just return -4.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove single use local variable
BALATON Zoltan [Sun, 26 May 2024 23:12:49 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove single use local variable

In mmu6xx_get_physical_address() tagtet_page_bits local is declared
only to use TARGET_PAGE_BITS once. Drop the unneeded variable.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Convert local variable to bool
BALATON Zoltan [Sun, 26 May 2024 23:12:48 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Convert local variable to bool

In mmu6xx_get_physical_address() ds is used as bool, declare it as
such. Also use named constant instead of hex value.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove nx field from mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:12:47 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove nx field from mmu_ctx_t

Pass it as a parameter instead. Also use named constants instead of
hex values when extracting bits from SR.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove pte_update_flags()
BALATON Zoltan [Sun, 26 May 2024 23:12:46 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove pte_update_flags()

This function is used only once, its return value is ignored and one
of its parameter is a return value from a previous call. It is better
to inline it in the caller and remove it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove hash field from mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:12:45 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove hash field from mmu_ctx_t

Return hash value via a parameter and remove it from mmu_ctx.t.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove unused field from mmu_ctx_t
BALATON Zoltan [Sun, 26 May 2024 23:12:44 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove unused field from mmu_ctx_t

The eaddr field of mmu_ctx_t is set once but never used so can be
removed.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Simplify ppc6xx_tlb_pte_check()
BALATON Zoltan [Sun, 26 May 2024 23:12:43 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Simplify ppc6xx_tlb_pte_check()

Invert conditions to avoid deep nested ifs and return early instead.
Remove some obvious comments that don't add more clarity.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Return directly in ppc6xx_tlb_pte_check()
BALATON Zoltan [Sun, 26 May 2024 23:12:42 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Return directly in ppc6xx_tlb_pte_check()

Instead of using a local ret variable return directly and remove the
local.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove yet another single use local variable
BALATON Zoltan [Sun, 26 May 2024 23:12:41 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove yet another single use local variable

In ppc6xx_tlb_pte_check() the pp variable is used only once to pass it
to a function parameter with the same name. Remove the local and
inline the value. Also use named constant for the hex value to make it
clearer.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove another single use local variable
BALATON Zoltan [Sun, 26 May 2024 23:12:40 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove another single use local variable

In ppc6xx_tlb_pte_check() the pteh variable is used only once to
compare to the h parameter of the function. Inline its value and use
pteh name for the function parameter which is more descriptive.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove single use local variable
BALATON Zoltan [Sun, 26 May 2024 23:12:39 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove single use local variable

The ptev variable in ppc6xx_tlb_pte_check() is used only once and just
obfuscates an otherwise clear value. Get rid of it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove single use local variable
BALATON Zoltan [Sun, 26 May 2024 23:12:38 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove single use local variable

The ptem variable in ppc6xx_tlb_pte_check() is used only once,
simplify by removing it as the value is already clear itself without
adding a local name for it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/mmu_common.c: Remove local name for a constant
BALATON Zoltan [Sun, 26 May 2024 23:12:37 +0000 (01:12 +0200)]
target/ppc/mmu_common.c: Remove local name for a constant

The mmask local variable is a less descriptive local name for a
constant. Drop it and use the constant directly in the two places it
is needed.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Reorganise and rename ppc_hash32_pp_prot()
BALATON Zoltan [Sun, 26 May 2024 23:12:36 +0000 (01:12 +0200)]
target/ppc: Reorganise and rename ppc_hash32_pp_prot()

Reorganise ppc_hash32_pp_prot() swapping the if legs so it does not
test for negative first and clean up to make it shorter. Also rename
it to ppc_hash32_prot().

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc : Update VSX storage access insns to use tcg_gen_qemu _ld/st_i128.
Chinmay Rath [Tue, 9 Jul 2024 11:43:41 +0000 (17:13 +0530)]
target/ppc : Update VSX storage access insns to use tcg_gen_qemu _ld/st_i128.

Updated many VSX instructions to use tcg_gen_qemu_ld/st_i128, instead of using
tcg_gen_qemu_ld/st_i64 consecutively.
Introduced functions {get,set}_vsr_full to facilitate the above & for future use.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Update VMX storage access insns to use tcg_gen_qemu_ld/st_i128.
Chinmay Rath [Tue, 9 Jul 2024 11:43:40 +0000 (17:13 +0530)]
target/ppc: Update VMX storage access insns to use tcg_gen_qemu_ld/st_i128.

Updated instructions {l, st}vx to use tcg_gen_qemu_ld/st_i128,
instead of using 64 bits loads/stores in succession.
Introduced functions {get, set}_avr_full in vmx-impl.c.inc to
facilitate the above, and potential future usage.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move get/set_avr64 functions to vmx-impl.c.inc.
Chinmay Rath [Tue, 9 Jul 2024 11:43:39 +0000 (17:13 +0530)]
target/ppc: Move get/set_avr64 functions to vmx-impl.c.inc.

Those functions are used to ld/st data to and from Altivec registers,
in 64 bits chunks, and are only used in vmx-impl.c.inc file,
hence the clean-up movement.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VSX fp compare insns to decodetree.
Chinmay Rath [Tue, 18 Jun 2024 08:58:31 +0000 (14:28 +0530)]
target/ppc: Move VSX fp compare insns to decodetree.

Moving the following instructions to decodetree specification:

xvcmp{eq, gt, ge, ne}{s, d}p : XX3-form

The changes were verified by validating that the tcg-ops generated for those
instructions remain the same which were captured using the '-d in_asm,op' flag.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VSX vector storage access insns to decodetree.
Chinmay Rath [Tue, 18 Jun 2024 08:58:30 +0000 (14:28 +0530)]
target/ppc: Move VSX vector storage access insns to decodetree.

Moving the following instructions to decodetree specification:

  lxv{b16, d2, h8, w4, ds, ws}x   : X-form
  stxv{b16, d2, h8, w4}x          : X-form

The changes were verified by validating that the tcg-ops generated for those
instructions remain the same, which were captured using the '-d in_asm,op' flag.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VSX vector with length storage access insns to decodetree.
Chinmay Rath [Tue, 18 Jun 2024 08:58:29 +0000 (14:28 +0530)]
target/ppc: Move VSX vector with length storage access insns to decodetree.

Moving the following instructions to decodetree specification :

        {l, st}xvl(l)           : X-form

The changes were verified by validating that the tcg-ops generated by those
instructions remain the same, which were captured using the '-d in_asm,op' flag.

Also added a new function do_ea_calc_ra to calculate the effective address :
EA <- (RA == 0) ? 0 : GPR[RA], which is now used by the above-said insns,
and shall be used later by (p){lx, stx}vp insns.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
[np: Fix 32-bit build]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Moving VSX scalar storage access insns to decodetree.
Chinmay Rath [Tue, 18 Jun 2024 08:58:28 +0000 (14:28 +0530)]
target/ppc: Moving VSX scalar storage access insns to decodetree.

Moving the following instructions to decodetree specification :

lxs{d, iwa, ibz, ihz, iwz, sp}x : X-form
stxs{d, ib, ih, iw, sp}x : X-form

The changes were verified by validating that the tcg-ops generated by those
instructions remain the same, which were captured using the '-d in_asm,op' flag.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VSX logical instructions to decodetree.
Chinmay Rath [Thu, 23 May 2024 09:48:21 +0000 (15:18 +0530)]
target/ppc: Move VSX logical instructions to decodetree.

Moving the following instructions to decodetree specification :

xxl{and, andc, or, orc, nor, xor, nand, eqv} : XX3-form

The changes were verified by validating that the tcg ops generated by those
instructions remain the same, which were captured with the '-d in_asm,op' flag.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VSX arithmetic and max/min insns to decodetree.
Chinmay Rath [Thu, 23 May 2024 09:48:20 +0000 (15:18 +0530)]
target/ppc: Move VSX arithmetic and max/min insns to decodetree.

Moving the following instructions to decodetree specification:

x{s, v}{add, sub, mul, div}{s, d}p : XX3-form
xs{max, min}dp, xv{max, min}{s, d}p : XX3-form

The changes were verfied by validating that the tcg ops generated by those
instructions remain the same, which were captured with the '-d in_asm,op' flag.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move ISA300 flag check out of do_helper_XX3.
Chinmay Rath [Thu, 23 May 2024 09:48:19 +0000 (15:18 +0530)]
target/ppc: Move ISA300 flag check out of do_helper_XX3.

Moving PPC2_ISA300 flag check out of do_helper_XX3 method in vmx-impl.c.inc
so that the helper can be used with other instructions as well.

Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Improve VMX integer add/sub saturate instructions.
Chinmay Rath [Thu, 23 May 2024 09:44:54 +0000 (15:14 +0530)]
target/ppc: Improve VMX integer add/sub saturate instructions.

No need for a full comparison; xor produces non-zero bits for QC just fine.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rath.chinmay@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move VMX integer add/sub saturate insns to decodetree.
Chinmay Rath [Thu, 23 May 2024 09:44:53 +0000 (15:14 +0530)]
target/ppc: Move VMX integer add/sub saturate insns to decodetree.

Moving the following instructions to decodetree specification :

v{add,sub}{u,s}{b,h,w}s : VX-form

The changes were verified by validating that the tcg ops generated by those
instructions remain the same, which were captured with the '-d in_asm,op' flag.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Dump more END state with 'info pic'
Frederic Barrat [Wed, 24 Jul 2024 21:21:30 +0000 (16:21 -0500)]
pnv/xive2: Dump more END state with 'info pic'

Additional END state 'info pic' information as added.  The 'ignore',
'crowd' and 'precluded escalation control' bits of an Event Notification
Descriptor are all used when delivering an interrupt targeting a VP-group
or crowd.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Refine TIMA 'info pic' output
Frederic Barrat [Wed, 24 Jul 2024 21:21:29 +0000 (16:21 -0500)]
pnv/xive2: Refine TIMA 'info pic' output

In XIVE Gen 2 there were some minor changes to the TIMA header that were
updated when printed.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Move xive2_nvp_pic_print_info() to xive2.c
Frederic Barrat [Wed, 24 Jul 2024 21:21:28 +0000 (16:21 -0500)]
pnv/xive2: Move xive2_nvp_pic_print_info() to xive2.c

Moving xive2_nvp_pic_print_info() to align with the other "pic_print_info"
functions.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Fail VST entry address computation if table has no VSD
Frederic Barrat [Wed, 24 Jul 2024 21:21:27 +0000 (16:21 -0500)]
pnv/xive2: Fail VST entry address computation if table has no VSD

Fail VST entry address computation if firmware doesn't define a descriptor
for one of the Virtualization Structure Tables (VST), there's no point in
trying to compute the address of its entry.  Abort the operation and log
an error.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Set Translation Table for the NVC port space
Frederic Barrat [Wed, 24 Jul 2024 21:21:26 +0000 (16:21 -0500)]
pnv/xive2: Set Translation Table for the NVC port space

Set Translation Table for the NVC port space is missing.  The xive model
doesn't take into account the remapping of IO operations via the Set
Translation Table but firmware is allowed to define it for the Notify
Virtual Crowd (NVC), like it's already done for the other VST tables.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Enable VST NVG and NVC index compression
Frederic Barrat [Wed, 24 Jul 2024 21:21:25 +0000 (16:21 -0500)]
pnv/xive2: Enable VST NVG and NVC index compression

Enable NVG and NVC VST tables for index compression which indicates the number
of bits the address is shifted to the right for the table accesses.
The compression values are defined as:
   0000 - No compression
   0001 - 1 bit shift
   0010 - 2 bit shift
   ....
   1000 - 8 bit shift
   1001-1111 - No compression

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Configure Virtualization Structure Tables through the PC
Frederic Barrat [Wed, 24 Jul 2024 21:21:24 +0000 (16:21 -0500)]
pnv/xive2: Configure Virtualization Structure Tables through the PC

Both the virtualization layer (VC) and presentation layer (PC) need to
be configured to access the VSTs. Since the information is redundant,
the xive model combines both into one set of tables and only the
definitions going through the VC are kept. The definitions through the
PC are ignored. That works well as long as firmware calls the VC for
all the tables.

For the NVG and NVC tables, it can make sense to only configure them
with the PC, since they are only used by the presenter. So this patch
allows firmware to configure the VST tables through the PC as well.
The definitions are still shared, since the VST tables can be set
through both the VC and/or PC, they are dynamically re-mapped in
memory by first deleting the memory subregion.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Add NVG and NVC to cache watch facility
Frederic Barrat [Wed, 24 Jul 2024 21:21:23 +0000 (16:21 -0500)]
pnv/xive2: Add NVG and NVC to cache watch facility

The cache watch facility uses the same register interface to handle
entries in the NVP, NVG and NVC tables. A bit-field in the 'watchX
specification' register tells the table type. So far, that bit-field
was not read and the code assumed a read/write to the NVP table.

This patch allows to read/write entries in the NVG and NVC table as
well.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive: Support cache flush and queue sync inject with notifications
Nicholas Piggin [Wed, 24 Jul 2024 21:21:22 +0000 (16:21 -0500)]
pnv/xive: Support cache flush and queue sync inject with notifications

Adds support for writing a completion notification byte in memory
whenever a cache flush or queue sync inject operation is requested by
software.  QEMU does not cache any of the XIVE data that is in memory and
therefore it simply writes the completion notification byte at the time
that the operation is requested.

Co-authored-by: Glenn Miles <milesg@linux.vnet.ibm.com>
Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: Structure/define alignment changes
Michael Kowal [Wed, 24 Jul 2024 21:21:21 +0000 (16:21 -0500)]
pnv/xive2: Structure/define alignment changes

Made changes to some structure and define elements to ease review in
next patchset.

Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agopnv/xive2: XIVE2 Cache Watch, Cache Flush and Sync Injection support
Frederic Barrat [Wed, 24 Jul 2024 21:21:20 +0000 (16:21 -0500)]
pnv/xive2: XIVE2 Cache Watch, Cache Flush and Sync Injection support

XIVE offers a 'cache watch facility', which allows software to read/update
a potentially cached table entry with no software lock. There's one such
facility in the Virtualization Controller (VC) to update the ESB and END
entries and one in the Presentation Controller (PC) to update the
NVP/NVG/NVC entries.

Each facility has 4 cache watch engines to control the updates and
firmware can request an available engine by querying the hardware
'watch_assign' register of the VC or PC. The engine is then reserved and
is released after the data is updated by reading the 'watch_spec' register
(which also allows to check for a conflict during the update).
If no engine is available, the special value 0xFF is returned and
firmware is expected to repeat the request until an engine becomes
available.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Kowal <kowal@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotests/qtest: Add pnv-spi-seeprom qtest
Chalapathi V [Wed, 26 Jun 2024 09:05:28 +0000 (04:05 -0500)]
tests/qtest: Add pnv-spi-seeprom qtest

In this commit Write a qtest pnv-spi-seeprom-test to check the
SPI transactions between spi controller and seeprom device.

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Acked-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Caleb Schlossin <calebs@linux.vnet.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agohw/ppc: SPI controller wiring to P10 chip
Chalapathi V [Wed, 26 Jun 2024 09:05:27 +0000 (04:05 -0500)]
hw/ppc: SPI controller wiring to P10 chip

In this commit, create SPI controller on p10 chip and connect cs irq.

The QOM tree of pnv-spi and seeprom are.
/machine (powernv10-machine)
  /chip[0] (power10_v2.0-pnv-chip)
    /pib_spic[2] (pnv-spi)
      /pnv-spi-bus.2 (SSI)
      /xscom-spi[0] (memory-region)

/machine (powernv10-machine)
  /peripheral-anon (container)
    /device[0] (25csm04)
      /WP#[0] (irq)
      /ssi-gpio-cs[0] (irq)

(qemu) qom-get /machine/peripheral-anon /device[76] "parent_bus"
"/machine/chip[0]/pib_spic[2]/pnv-spi-bus.2"

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agohw/block: Add Microchip's 25CSM04 to m25p80
Chalapathi V [Wed, 26 Jun 2024 09:05:26 +0000 (04:05 -0500)]
hw/block: Add Microchip's 25CSM04 to m25p80

Add Microchip's 25CSM04 Serial EEPROM to m25p80.  25CSM04 provides 4 Mbits
of Serial EEPROM utilizing the Serial Peripheral Interface (SPI) compatible
bus. The device is organized as 524288 bytes of 8 bits each (512Kbyte) and
is optimized for use in consumer and industrial applications where reliable
and dependable nonvolatile memory storage is essential.

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agohw/ssi: Extend SPI model
Chalapathi V [Wed, 26 Jun 2024 09:05:25 +0000 (04:05 -0500)]
hw/ssi: Extend SPI model

In this commit SPI shift engine and sequencer logic is implemented.
Shift engine performs serialization and de-serialization according to the
control by the sequencer and according to the setup defined in the
configuration registers. Sequencer implements the main control logic and
FSM to handle data transmit and data receive control of the shift engine.

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Reviewed-by: Caleb Schlossin <calebs@linux.vnet.ibm.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agohw/ssi: Add SPI model
Chalapathi V [Wed, 26 Jun 2024 09:05:24 +0000 (04:05 -0500)]
hw/ssi: Add SPI model

SPI controller device model supports a connection to a single SPI responder.
This provide access to SPI seeproms, TPM, flash device and an ADC controller.

All SPI function control is mapped into the SPI register space to enable full
control by firmware. In this commit SPI configuration component is modelled
which contains all SPI configuration and status registers as well as the hold
registers for data to be sent or having been received.

An existing QEMU SSI framework is used and SSI_BUS is created.

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Reviewed-by: Caleb Schlossin <calebs@linux.vnet.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
[np: Fix FDT macro compile for qtest]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Remove ppc target dependency from pnv_xscom.h
Chalapathi V [Wed, 26 Jun 2024 09:05:23 +0000 (04:05 -0500)]
ppc/pnv: Remove ppc target dependency from pnv_xscom.h

In this commit target specific dependency from include/hw/ppc/pnv_xscom.h
has been removed so that pnv_xscom.h can be included outside hw/ppc.

Signed-off-by: Chalapathi V <chalapathi.v@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Caleb Schlossin <calebs@linux.vnet.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add an LPAR per core machine option
Nicholas Piggin [Fri, 24 May 2024 05:02:46 +0000 (15:02 +1000)]
ppc/pnv: Add an LPAR per core machine option

Recent POWER CPUs can operate in "LPAR per core" or "LPAR per thread"
modes. In per-core mode, some SPRs and IPI doorbells are shared between
threads in a core. In per-thread mode, supervisor and user state is
not shared between threads.

OpenPOWER systems after POWER8 use LPAR per thread mode, and it is
required for KVM. Enterprise systems use LPAR per core mode, as they
partition the machine by core.

Implement a lpar-per-core machine option for powernv machines. This
is fixed true for POWER8 machines, and defaults off for P9 and P10.

With this change, powernv8 SMT now works sufficiently to run Linux,
with a single socket. Multi-threaded KVM guests still have problems,
as does multi-socket Linux boot.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Implement POWER10 PC xscom registers for direct controls
Nicholas Piggin [Thu, 16 May 2024 13:44:12 +0000 (23:44 +1000)]
ppc/pnv: Implement POWER10 PC xscom registers for direct controls

The PC unit in the processor core contains xscom registers that provide
low level status and control of the CPU.

This implements "direct controls", sufficient for skiboot firmware,
which uses it to send NMI IPIs between CPUs.

POWER10 is sufficiently different from POWER9 (particularly with respect
to QME and special wakeup) that it is not trivial to implement POWER9
support by reusing the code.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add a CPU nmi and resume function
Nicholas Piggin [Fri, 12 Jul 2024 03:16:44 +0000 (13:16 +1000)]
ppc/pnv: Add a CPU nmi and resume function

Power CPUs have an execution control facility that can pause, resume,
and cause NMIs, among other things. Add a function that will nmi a CPU
and resume it if it was paused, in preparation for implementing the
control facility.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add big-core machine property
Nicholas Piggin [Tue, 18 Jun 2024 02:45:34 +0000 (12:45 +1000)]
ppc/pnv: Add big-core machine property

Big-core implementation is complete, so expose it as a machine
property that may be set with big-core=on option on powernv9 and
powernv10 machines.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add POWER10 ChipTOD quirk for big-core
Nicholas Piggin [Tue, 18 Jun 2024 03:09:54 +0000 (13:09 +1000)]
ppc/pnv: Add POWER10 ChipTOD quirk for big-core

POWER10 has a quirk in its ChipTOD addressing that requires the even
small-core to be selected even when programming the odd small-core.
This allows skiboot chiptod init to run in big-core mode.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Implement Power9 CPU core thread state indirect register
Nicholas Piggin [Thu, 11 Jul 2024 08:31:35 +0000 (18:31 +1000)]
ppc/pnv: Implement Power9 CPU core thread state indirect register

Power9 CPUs have a core thread state register accessible via SPRC/SPRD
indirect registers. This register includes a bit for big-core mode,
which skiboot requires.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Implement big-core PVR for Power9/10
Nicholas Piggin [Thu, 11 Jul 2024 08:37:25 +0000 (18:37 +1000)]
ppc/pnv: Implement big-core PVR for Power9/10

Power9/10 CPUs have PVR[51] set in small-core mode and clear in big-core
mode. This is used by skiboot firmware.

PVR is not hypervisor-privileged but it is not so important that spapr
to implement this because it's generally masked out of PVR matching code
in kernels, and only used by firmware.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add allow for big-core differences in DT generation
Nicholas Piggin [Thu, 11 Jul 2024 09:06:14 +0000 (19:06 +1000)]
ppc/pnv: Add allow for big-core differences in DT generation

device-tree building needs to account for big-core mode, because it is
driven by qemu cores (small cores). Every second core should be skipped,
and every core should describe threads for both small-cores that make
up the big core.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add a big-core mode that joins two regular cores
Nicholas Piggin [Thu, 16 May 2024 05:25:12 +0000 (15:25 +1000)]
ppc/pnv: Add a big-core mode that joins two regular cores

POWER9 and POWER10 machines come in two variants, big-core and
small-core. Big-core machines are SMT8 from software's point of view,
but the low level platform topology ("xscom registers and pervasive
addressing"), these look more like a pair of small cores ganged
together.

Presently the way this is modelled is to create one SMT8 PnvCore and add
special cases to xscom and pervasive for big-core mode that tries to
split this into two small cores, but this is becoming too complicated to
manage.

A better approach is to create 2 core structures and ganging them
together to look like an SMT8 core in TCG. Then the xscom and pervasive
models mostly do not need to differentiate big and small core modes.

This change adds initial mode bits and QEMU topology handling to
split SMT8 cores into 2xSMT4 cores.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc: Add has_smt_siblings property to CPUPPCState
Nicholas Piggin [Tue, 18 Jun 2024 02:56:53 +0000 (12:56 +1000)]
ppc: Add has_smt_siblings property to CPUPPCState

The decision to branch out to a slower SMT path in instruction
emulation will become a bit more complicated with the way that
"big-core" topology that will be implemented in subsequent changes.
Hide these details from the wider CPU emulation code with a bool
has_smt_siblings flag that can be set by machine initialisation.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Add helpers to check for SMT sibling threads
Nicholas Piggin [Fri, 24 May 2024 07:49:52 +0000 (17:49 +1000)]
target/ppc: Add helpers to check for SMT sibling threads

Add helpers for TCG code to determine if there are SMT siblings
sharing per-core and per-lpar registers. This simplifies the
callers and makes SMT register topology simpler to modify with
later changes.

Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc: Add a core_index to CPUPPCState for SMT vCPUs
Nicholas Piggin [Thu, 16 May 2024 05:25:12 +0000 (15:25 +1000)]
ppc: Add a core_index to CPUPPCState for SMT vCPUs

The way SMT thread siblings are matched is clunky, using hard-coded
logic that checks the PIR SPR.

Change that to use a new core_index variable in the CPUPPCState,
where all siblings have the same core_index. CPU realize routines have
flexibility in setting core/sibling topology.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Extend chip_pir class method to TIR as well
Nicholas Piggin [Fri, 24 May 2024 01:54:09 +0000 (11:54 +1000)]
ppc/pnv: Extend chip_pir class method to TIR as well

The chip_pir chip class method allows the platform to set the PIR
processor identification register. Extend this to a more general
ID function which also allows the TIR to be set. This is in
preparation for "big core", which is a more complicated topology
of cores and threads.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: use class attribute to limit SMT threads for different machines
Nicholas Piggin [Fri, 24 May 2024 05:52:04 +0000 (15:52 +1000)]
ppc/pnv: use class attribute to limit SMT threads for different machines

Use a class attribute to specify the number of SMT threads per core
permitted for different machines, 8 for powernv8 and 4 for powernv9/10.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Move SPR indirect registers into PnvCore
Nicholas Piggin [Sun, 26 May 2024 11:24:00 +0000 (21:24 +1000)]
target/ppc: Move SPR indirect registers into PnvCore

SPRC/SPRD were recently added to all BookS CPUs supported, but
they are only tested on POWER9 and POWER10, so restrict them to
those CPUs.

SPR indirect scratch registers presently replicated per-CPU like
SMT SPRs, but the PnvCore is a better place for them since they
are restricted to P9/P10.

Also add SPR indirect read access to core thread state for POWER9
since skiboot accesses that when booting to check for big-core
mode.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Move timebase state into PnvCore
Nicholas Piggin [Fri, 24 May 2024 11:58:18 +0000 (21:58 +1000)]
ppc/pnv: Move timebase state into PnvCore

The timebase state machine is per per-core state and can be driven
by any thread in the core. It is currently implemented as a hack
where the state is in a CPU structure and only thread 0's state is
accessed by the chiptod, which limits programming the timebase
side of the state machine to thread 0 of a core.

Move the state out into PnvCore and share it among all threads.

Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Add pointer from PnvCPUState to PnvCore
Nicholas Piggin [Sun, 26 May 2024 05:04:05 +0000 (15:04 +1000)]
ppc/pnv: Add pointer from PnvCPUState to PnvCore

This helps move core state from CPU to core structures.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: Fix msgsnd for POWER8
Nicholas Piggin [Sat, 6 Jul 2024 03:22:58 +0000 (13:22 +1000)]
target/ppc: Fix msgsnd for POWER8

POWER8 (ISA v2.07S) introduced the doorbell facility, the msgsnd
instruction behaved mostly like msgsndp, it was addressed by TIR
and could only send interrupts between threads on the core.

ISA v3.0 changed msgsnd to be addressed by PIR and can interrupt
any thread in the system.

msgsnd only implements the v3.0 semantics, which can make
multi-threaded POWER8 hang when booting Linux (due to IPIs
failing). This change adds v2.07 semantics.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Implement ADU access to LPC space
Nicholas Piggin [Wed, 17 Apr 2024 04:50:13 +0000 (14:50 +1000)]
ppc/pnv: Implement ADU access to LPC space

One of the functions of the ADU is indirect memory access engines that
send and receive data via ADU registers.

This implements the ADU LPC memory access functionality sufficiently
for IBM proprietary firmware to access the UART and print characters
to the serial port as it does on real hardware.

This requires a linkage between adu and lpc, which allows adu to
perform memory access in the lpc space.

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Begin a more complete ADU LPC model for POWER9/10
Nicholas Piggin [Fri, 23 Feb 2024 12:34:56 +0000 (22:34 +1000)]
ppc/pnv: Begin a more complete ADU LPC model for POWER9/10

This implements a framework for an ADU unit model.

The ADU unit actually implements XSCOM, which is the bridge between MMIO
and PIB. However it also includes control and status registers and other
functions that are exposed as PIB (xscom) registers.

To keep things simple, pnv_xscom.c remains the XSCOM bridge
implementation, and pnv_adu.c implements the ADU registers and other
functions.

So far, just the ADU no-op registers in the pnv_xscom.c default handler
are moved over to the adu model.

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Implement POWER9 LPC PSI serirq outputs and auto-clear function
Nicholas Piggin [Fri, 10 May 2024 07:10:40 +0000 (17:10 +1000)]
ppc/pnv: Implement POWER9 LPC PSI serirq outputs and auto-clear function

The POWER8 LPC ISA device irqs all get combined and reported to the line
connected the PSI LPCHC irq. POWER9 changed this so only internal LPC
host controller irqs use that line, and the device irqs get routed to
4 new lines connected to PSI SERIRQ0-3.

POWER9 also introduced a new feature that automatically clears the irq
status in the LPC host controller when EOI'ed, so software does not have
to.

The powernv OPAL (skiboot) firmware managed to work because the LPCHC
irq handler scanned all LPC irqs and handled those including clearing
status even on POWER9 systems. So LPC irqs worked despite OPAL thinking
it was running in POWER9 mode. After this change, UART interrupts show
up on serirq1 which is where OPAL routes them to:

 cat /proc/interrupts
 ...
 20:          0  XIVE-IRQ 1048563 Level     opal-psi#0:lpchc
 ...
 25:         34  XIVE-IRQ 1048568 Level     opal-psi#0:lpc_serirq_mux1

Whereas they previously turn up on lpchc.

Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Fix loss of LPC SERIRQ interrupts
Glenn Miles [Fri, 24 May 2024 18:24:14 +0000 (13:24 -0500)]
ppc/pnv: Fix loss of LPC SERIRQ interrupts

The LPC HC irq status register bits are set when an LPC IRQSER input is
asserted. These irq status bits drive the PSI irq to the CPU interrupt
controller. The LPC HC irq status bits are cleared by software writing
to the register with 1's for the bits to clear.

Existing register write was clearing the irq status bits even when the
input was asserted, this results in interrupts being lost.

This fix changes the behavior to keep track of the device IRQ status
in internal state that is separate from the irq status register, and
only allowing the irq status bits to be cleared if the associated
input is not asserted.

Signed-off-by: Glenn Miles <milesg@linux.ibm.com>
[np: rebased before P9 PSI SERIRQ patch, adjust changelog/comments]
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/pnv: Update Power10's cfam id to use Power10 DD2
Aditya Gupta [Thu, 2 May 2024 06:27:01 +0000 (11:57 +0530)]
ppc/pnv: Update Power10's cfam id to use Power10 DD2

Power10 DD1.0 was dropped in:

    commit 8f054d9ee825 ("ppc: Drop support for POWER9 and POWER10 DD1 chips")

Use the newer Power10 DD2 chips cfam id.

Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/cpu_init: Synchronize HASHPKEYR with KVM for migration
Shivaprasad G Bhat [Wed, 5 Jun 2024 15:58:22 +0000 (15:58 +0000)]
target/ppc/cpu_init: Synchronize HASHPKEYR with KVM for migration

The patch enables HASHPKEYR migration by hooking with the
"KVM one reg" ID KVM_REG_PPC_HASHPKEYR.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/cpu_init: Synchronize HASHKEYR with KVM for migration
Shivaprasad G Bhat [Wed, 5 Jun 2024 15:58:12 +0000 (15:58 +0000)]
target/ppc/cpu_init: Synchronize HASHKEYR with KVM for migration

The patch enables HASHKEYR migration by hooking with the
"KVM one reg" ID KVM_REG_PPC_HASHKEYR.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/cpu_init: Synchronize DEXCR with KVM for migration
Shivaprasad G Bhat [Wed, 5 Jun 2024 15:58:02 +0000 (15:58 +0000)]
target/ppc/cpu_init: Synchronize DEXCR with KVM for migration

The patch enables DEXCR migration by hooking with the
"KVM one reg" ID KVM_REG_PPC_DEXCR.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agolinux-header: PPC: KVM: Update one-reg ids for DEXCR, HASHKEYR and HASHPKEYR
Shivaprasad G Bhat [Wed, 5 Jun 2024 15:57:52 +0000 (15:57 +0000)]
linux-header: PPC: KVM: Update one-reg ids for DEXCR, HASHKEYR and HASHPKEYR

This is a placeholder change for these SPRs until the full linux
header update.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc/arch_dump: set prstatus pid to cpuid
Omar Sandoval [Fri, 19 Jul 2024 18:39:05 +0000 (11:39 -0700)]
target/ppc/arch_dump: set prstatus pid to cpuid

Every other architecture does this, and debuggers need it to be able to
identify which prstatus note corresponds to which CPU.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotarget/ppc: handle vcpu hotplug failure gracefully
Harsh Prateek Bora [Tue, 18 Jun 2024 08:23:54 +0000 (13:53 +0530)]
target/ppc: handle vcpu hotplug failure gracefully

On ppc64, the PowerVM hypervisor runs with limited memory and a VCPU
creation during hotplug may fail during kvm_ioctl for KVM_CREATE_VCPU,
leading to termination of guest since errp is set to &error_fatal while
calling kvm_init_vcpu. This unexpected behaviour can be avoided by
pre-creating and parking vcpu on success or return error otherwise.
This enables graceful error delivery for any vcpu hotplug failures while
the guest can keep running.

Also introducing KVM AccelCPUClass to init cpu_target_realize for kvm.

Tested OK by repeatedly doing a hotplug/unplug of vcpus as below:

 #virsh setvcpus hotplug 40
 #virsh setvcpus hotplug 70
error: internal error: unable to execute QEMU command 'device_add':
kvmppc_cpu_realize: vcpu hotplug failed with -12

Signed-off by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Reported-by: Anushree Mathur <anushree.mathur@linux.vnet.ibm.com>
Suggested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Tested-by: Anushree Mathur <anushree.mathur@linux.vnet.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agocpu-common.c: export cpu_get_free_index to be reused later
Harsh Prateek Bora [Tue, 18 Jun 2024 08:23:53 +0000 (13:53 +0530)]
cpu-common.c: export cpu_get_free_index to be reused later

This helper provides an easy way to identify the next available free cpu
index which can be used for vcpu creation. Until now, this is being
called at a very later stage and there is a need to be able to call it
earlier (for now, with ppc64) hence the need to export.

Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoaccel/kvm: Introduce kvm_create_and_park_vcpu() helper
Harsh Prateek Bora [Tue, 18 Jun 2024 08:23:52 +0000 (13:53 +0530)]
accel/kvm: Introduce kvm_create_and_park_vcpu() helper

There are distinct helpers for creating and parking a KVM vCPU.
However, there can be cases where a platform needs to create and
immediately park the vCPU during early stages of vcpu init which
can later be reused when vcpu thread gets initialized. This would
help detect failures with kvm_create_vcpu at an early stage.

Suggested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoppc/vof: Fix unaligned FDT property access
Akihiko Odaki [Mon, 8 Jul 2024 06:55:13 +0000 (15:55 +0900)]
ppc/vof: Fix unaligned FDT property access

FDT properties are aligned by 4 bytes, not 8 bytes.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agospapr: Free stdout path
Akihiko Odaki [Mon, 8 Jul 2024 06:55:12 +0000 (15:55 +0900)]
spapr: Free stdout path

This fixes LeakSanitizer warnings.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agospapr: Migrate ail-mode-3 spapr cap
Nicholas Piggin [Mon, 6 May 2024 11:56:05 +0000 (21:56 +1000)]
spapr: Migrate ail-mode-3 spapr cap

This cap did not add the migration code when it was introduced. This
results in migration failure when changing the default using the
command line.

Cc: qemu-stable@nongnu.org
Fixes: ccc5a4c5e10 ("spapr: Add SPAPR_CAP_AIL_MODE_3 for AIL mode 3 support for H_SET_MODE hcall")
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agotests/tcg: Skip failing ppc64 multi-threaded tests
Nicholas Piggin [Thu, 25 Jul 2024 14:50:31 +0000 (00:50 +1000)]
tests/tcg: Skip failing ppc64 multi-threaded tests

In Gitlab CI, some ppc64 multi-threaded tcg tests crash when run in the
clang-user job with an assertion failure in glibc that seems to
indicate corruption:

  signals: allocatestack.c:223: allocate_stack:
    Assertion `powerof2 (pagesize_m1 + 1)' failed.

Disable these tests for now.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
8 months agoMerge tag 'bsd-user-for-9.1-pull-request' of gitlab.com:bsdimp/qemu into staging
Richard Henderson [Wed, 24 Jul 2024 23:53:57 +0000 (09:53 +1000)]
Merge tag 'bsd-user-for-9.1-pull-request' of gitlab.com:bsdimp/qemu into staging

bsd-user: Misc changes for 9.1 (I hope)

V2: Add missing bsd-user/aarch64/target.h

This patch series includes two main sets of patches. To make it simple to
review, I've included the changes from my student which the later changes depend
on. I've included a change from Jessica and Doug as well. I've reviewed them,
but more eyes never hurt.

I've also included a number of 'touch up' patches needed either to get the
aarch64 building, or to implmement suggestions from prior review cycles. The
main one is what's charitably described as a kludge: force aarch64 to use 4k
pages. The qemu-project (and blitz branch) hasn't had the necessary changes to
bsd-user needed to support variable page size.

Sorry this is so late... Live has conspired to delay me.

# -----BEGIN PGP SIGNATURE-----
# Comment: GPGTools - https://gpgtools.org
#
# iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmahejwACgkQbBzRKH2w
# EQCXuQ/+Pj1Izmox/y9X1trn1T8KC7JdMtimdLiGMaS4C6+gcThXJkIB4l9ZStbV
# 7rI540mpqVf0KSRLYwc2/ATyhYU7Ffsz02WPn7Xn/NvmmITp4kjw9Z0gd7C7mPVq
# fS8DJbTyFQDy5dO8FUKLaTfnlYQe+NCnL421t9wFkIrlEepFygRaBaJN5yWVoC+0
# 1Ob6dG+JEV5BmNguMufvvI3S7nEFEnSBGpNqW3ljrRHAZjdNhv8d9GBYbj1laR1r
# HQ6r5+u4ZmKCuUbchS0jxGkug0DjuQC7iq+rQ/7fhLYLChkPZ4P2RxNv8ibzKjEV
# wlTy5LaM+WZNzKWdcHfDFMomeSnnUkOOfAMipMney2jedEjTIwCFDnP4zCAuG83V
# RbdXWfleP1rDto3AQ765pFneqm3+su2Dh4TKaTSnq6gd1eORJ2IL8dubCfcVwZCy
# TofemXPWh0HX3kwlD9IB9rqplQZFL78TkQ47btftxinHCLCQOOHRDPVG0IahQPjo
# pgK4yVH7WA7pWV2Xbo4ngG3sX5U1TyBCbfkkAwhq+P3gjnU8zxonx8Tk/qLeEDdH
# KEypi/pkGFQKZY0wc/y4XM+XQh6E1l8gMaQ4gJWK1qlyVtUKM1BiNQ2lweohYzC8
# p6WAfBQLPpzY4mDWfJMF6DsgObLwWmYbgKzuOtHgST1D/Ebk3Zo=
# =RPuN
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 25 Jul 2024 08:03:40 AM AEST
# gpg:                using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100
# gpg: Good signature from "Warner Losh <wlosh@netflix.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@bsdimp.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@freebsd.org>" [unknown]
# gpg:                 aka "Warner Losh <imp@village.org>" [unknown]
# gpg:                 aka "Warner Losh <wlosh@bsdimp.com>" [unknown]
# 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: 2035 F894 B00A A3CF 7CCD  E1B7 6C1C D128 7DB0 1100

* tag 'bsd-user-for-9.1-pull-request' of gitlab.com:bsdimp/qemu:
  bsd-user: Add target.h for aarch64.
  bsd-user: Add aarch64 build to tree
  bsd-user: Make compile for non-linux user-mode stuff
  bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack
  bsd-user: Sync fork_start/fork_end with linux-user
  bsd-user: Hard wire aarch64 to be 4k pages only
  bsd-user: Simplify the implementation of execve
  bsd-user:Add AArch64 improvements and signal handling functions
  bsd-user:Add set_mcontext function for ARM AArch64
  bsd-user:Add setup_sigframe_arch function for ARM AArch64
  bsd-user:Add get_mcontext function for ARM AArch64
  bsd-user:Add ARM AArch64 signal handling support
  bsd-user:Add ARM AArch64 support and capabilities
  bsd-user:Add AArch64 register handling and related functions
  bsd-user:Add CPU initialization and management functions

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8 months agobsd-user: Add target.h for aarch64.
Warner Losh [Wed, 24 Jul 2024 21:57:44 +0000 (15:57 -0600)]
bsd-user: Add target.h for aarch64.

For aarch64, it's a 64-bit API, so there's no pairing of registers for
64-bit values.

Signed-off-by: Warner Losh <imp@bsdimp.com>
8 months agoMerge tag 'misc-fixes-pull-request' of https://gitlab.com/berrange/qemu into staging
Richard Henderson [Wed, 24 Jul 2024 11:35:10 +0000 (21:35 +1000)]
Merge tag 'misc-fixes-pull-request' of https://gitlab.com/berrange/qemu into staging

Crypto patches

* Drop unused 'detached-header' QAPI field from LUKS create options
* Improve tracing of TLS sockets and TLS chardevs
* Improve error messages from TLS I/O failures
* Add docs about use of LUKS detached header options
* Allow building without libtasn1, but with GNUTLS
* Fix detection of libgcrypt when libgcrypt-config is absent

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE2vOm/bJrYpEtDo4/vobrtBUQT98FAmagzXUACgkQvobrtBUQ
# T9++chAAhCFgo5A/UjQGdl9UAOW/sdgOoHGE3E8Y6sSTQyv+EfHf1DO89JtAh4ft
# d8Hz7Taul4k1wRm6Dxv2aCqH5iS1tgDE2ghGDNwn/zDtHNnjFx3+HcxBaAEcpt3O
# FqvGeG6KdFO1t2UR2DMh1XbhfwygrHiIcSB2y8jrgi46ncS6JvLrFavjLTe7JBn9
# J3y/iYgQiVPN6UlIwUs1EquGdoTI/0SpHVirqHN/2yyrdRsGBsXZq5WI6Oli8zFL
# VqJNmc5Dzo7ushoYG5Rpk83mmC26VuXO/JmXyJ/c7FeADLWUfc/SPPyAMxPGuwFr
# DKg84ovRtq3yZIw8LPoUJOtbcu4Y7BSGwlolQjWegvsVTU6Bdk+teZVR9X64QbM2
# YBXzMkRHUKzR3rb0LewAKehP3n93aBypLln9ZMgg7wj92Rj8Dl/sylaBhDEkH/HQ
# 2pMdSdAWqMnGHfnKPxyjflNO2PIsOenZUkDZwf9i7Ow6fU5n3fqvudVDTWjXpWPn
# V7v9JGNPHocScJFRUqHSVqd2ZWaZX4F1TsvG6SGOmzDGR0IjBRlqos7OEdbAAH1x
# IglizbTxD6M9ZWJrGt1sl6LSAwEp3oXgsWNdejq2+7I6H4BeUm4ACDbdrEjqG9aG
# Ya/HpNT0PEzbGXm6qsuHY5z0agGtaPwdXLcSGnsv+a0rP/9nthY=
# =ccYf
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 24 Jul 2024 07:46:29 PM AEST
# gpg:                using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [full]
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>" [full]

* tag 'misc-fixes-pull-request' of https://gitlab.com/berrange/qemu:
  crypto: propagate errors from TLS session I/O callbacks
  crypto: push error reporting into TLS session I/O APIs
  crypto: drop gnutls debug logging support
  chardev: add tracing of socket error conditions
  meson: build chardev trace files when have_block
  qapi: drop unused QCryptoBlockCreateOptionsLUKS.detached-header
  meson.build: fix libgcrypt detection on system without libgcrypt-config
  docs/devel: Add introduction to LUKS volume with detached header
  crypto: Allow building with GnuTLS but without Libtasn1
  crypto: Restrict pkix_asn1_tab[] to crypto-tls-x509-helpers.c
  crypto: Remove 'crypto-tls-x509-helpers.h' from crypto-tls-psk-helpers.c

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8 months agocrypto: propagate errors from TLS session I/O callbacks
Daniel P. Berrangé [Fri, 15 Mar 2024 14:29:11 +0000 (14:29 +0000)]
crypto: propagate errors from TLS session I/O callbacks

GNUTLS doesn't know how to perform I/O on anything other than plain
FDs, so the TLS session provides it with some I/O callbacks. The
GNUTLS API design requires these callbacks to return a unix errno
value, which means we're currently loosing the useful QEMU "Error"
object.

This changes the I/O callbacks in QEMU to stash the "Error" object
in the QCryptoTLSSession class, and fetch it when seeing an I/O
error returned from GNUTLS, thus preserving useful error messages.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
8 months agocrypto: push error reporting into TLS session I/O APIs
Daniel P. Berrangé [Fri, 15 Mar 2024 14:07:58 +0000 (14:07 +0000)]
crypto: push error reporting into TLS session I/O APIs

The current TLS session I/O APIs just return a synthetic errno
value on error, which has been translated from a gnutls error
value. This looses a large amount of valuable information that
distinguishes different scenarios.

Pushing population of the "Error *errp" object into the TLS
session I/O APIs gives more detailed error information.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
8 months agocrypto: drop gnutls debug logging support
Daniel P. Berrangé [Fri, 15 Mar 2024 13:54:52 +0000 (13:54 +0000)]
crypto: drop gnutls debug logging support

GNUTLS already supports dynamically enabling its logging at runtime by
setting the env var 'GNUTLS_DEBUG_LEVEL=10', so there is no need to
re-invent this logic in QEMU in a way that requires a re-compile.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>