Skip to content

Commit 1102393

Browse files
committed
Discover TSM capabilities as part of the GetTsmInfo call.
Signed-off-by: Wojciech Ozga <woz@zurich.ibm.com>
1 parent 7fce0e5 commit 1102393

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

arch/riscv/include/asm/kvm_cove.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
#include <asm/csr.h>
2020
#include <asm/sbi.h>
2121

22+
#define KVM_COVE_TSM_CAP_PROMOTE_TVM 0x0
23+
#define KVM_COVE_TSM_CAP_ATTESTATION_LOCAL 0x1
24+
#define KVM_COVE_TSM_CAP_ATTESTATION_REMOTE 0x2
25+
#define KVM_COVE_TSM_CAP_AIA 0x3
26+
#define KVM_COVE_TSM_CAP_MRIF 0x4
27+
#define KVM_COVE_TSM_CAP_MEMORY_ALLOCATION 0x5
28+
2229
#define KVM_COVE_PAGE_SIZE_4K (1UL << 12)
2330
#define KVM_COVE_PAGE_SIZE_2MB (1UL << 21)
2431
#define KVM_COVE_PAGE_SIZE_1GB (1UL << 30)
@@ -126,6 +133,7 @@ static inline bool is_cove_vcpu(struct kvm_vcpu *vcpu)
126133
#ifdef CONFIG_RISCV_COVE_HOST
127134

128135
bool kvm_riscv_cove_enabled(void);
136+
bool kvm_riscv_cove_capability(unsigned long cap);
129137
int kvm_riscv_cove_init(void);
130138

131139
/* TVM related functions */
@@ -158,6 +166,7 @@ int kvm_riscv_cove_aia_convert_imsic(struct kvm_vcpu *vcpu, phys_addr_t imsic_pa
158166
int kvm_riscv_cove_vcpu_imsic_addr(struct kvm_vcpu *vcpu);
159167
#else
160168
static inline bool kvm_riscv_cove_enabled(void) {return false; };
169+
static inline bool kvm_riscv_cove_capability(unsigned long cap) { return false; };
161170
static inline int kvm_riscv_cove_init(void) { return -1; }
162171
static inline void kvm_riscv_cove_hardware_disable(void) {}
163172
static inline int kvm_riscv_cove_hardware_enable(void) {return 0; }

arch/riscv/include/asm/sbi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,15 @@ struct sbi_cove_tsm_info {
410410
/* Current state of the TSM */
411411
enum sbi_cove_tsm_state tstate;
412412

413+
/* TSM implementation identifier */
414+
uint32_t impl_id;
415+
413416
/* Version of the loaded TSM */
414417
uint32_t version;
415418

419+
/* Capabilities of the TSM */
420+
unsigned long capabilities;
421+
416422
/* Number of 4K pages required per TVM */
417423
unsigned long tvm_pages_needed;
418424

arch/riscv/kvm/cove.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ __always_inline bool kvm_riscv_cove_enabled(void)
150150
return riscv_cove_enabled;
151151
}
152152

153+
__always_inline bool kvm_riscv_cove_capability(unsigned long cap)
154+
{
155+
return tinfo.capabilities & BIT(cap);
156+
}
157+
153158
static void kvm_cove_imsic_clone(void *info)
154159
{
155160
int rc;

0 commit comments

Comments
 (0)