mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 06:31:58 +02:00
Use u64 instead of uint64_t to make the KVM selftests code more concise and more similar to the kernel (since selftests are primarily developed by kernel developers). This commit was generated with the following command: git ls-files tools/testing/selftests/kvm | xargs sed -i 's/uint64_t/u64/g' Then by manually adjusting whitespace to make checkpatch.pl happy. Include <linux/types.h> in include/kvm_util_types.h, iinclude/test_util.h, and include/x86/pmu.h to pick up the tools-defined u64. Arguably, all headers (especially kvm_util_types.h) should have already been including stdint.h to get uint64_t from the libc headers, but the missing dependency only rears its head once KVM uses u64 instead of uint64_t. No functional change intended. Signed-off-by: David Matlack <dmatlack@google.com> [sean: rename pread_uint64() => pread_u64, expand on types.h include] Link: https://patch.msgid.link/20260420212004.3938325-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright IBM Corp. 2024
|
|
*
|
|
* Authors:
|
|
* Hariharan Mari <hari55@linux.ibm.com>
|
|
*
|
|
* Get the facility bits with the STFLE instruction
|
|
*/
|
|
|
|
#ifndef SELFTEST_KVM_FACILITY_H
|
|
#define SELFTEST_KVM_FACILITY_H
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
/* alt_stfle_fac_list[16] + stfle_fac_list[16] */
|
|
#define NB_STFL_DOUBLEWORDS 32
|
|
|
|
extern u64 stfl_doublewords[NB_STFL_DOUBLEWORDS];
|
|
extern bool stfle_flag;
|
|
|
|
static inline bool test_bit_inv(unsigned long nr, const unsigned long *ptr)
|
|
{
|
|
return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
|
|
}
|
|
|
|
static inline void stfle(u64 *fac, unsigned int nb_doublewords)
|
|
{
|
|
register unsigned long r0 asm("0") = nb_doublewords - 1;
|
|
|
|
asm volatile(" .insn s,0xb2b00000,0(%1)\n"
|
|
: "+d" (r0)
|
|
: "a" (fac)
|
|
: "memory", "cc");
|
|
}
|
|
|
|
static inline void setup_facilities(void)
|
|
{
|
|
stfle(stfl_doublewords, NB_STFL_DOUBLEWORDS);
|
|
stfle_flag = true;
|
|
}
|
|
|
|
static inline bool test_facility(int nr)
|
|
{
|
|
if (!stfle_flag)
|
|
setup_facilities();
|
|
return test_bit_inv(nr, stfl_doublewords);
|
|
}
|
|
|
|
#endif
|