Skip to content

Commit

Permalink
RISC-V: Remove redundant timer event from struct riscv_priv_nested
Browse files Browse the repository at this point in the history
The timer event in struct riscv_priv_nested was intended to be used for
nested guest but we have separate timer event in cpu_vcpu_timer for this
purpose so let us remove timer event from struct riscv_priv_nested.

Signed-off-by: Anup Patel <[email protected]>
  • Loading branch information
avpatel committed Jul 1, 2024
1 parent a8c5e49 commit fb46e69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
23 changes: 1 addition & 22 deletions arch/riscv/cpu/generic/cpu_vcpu_nested.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,40 +796,25 @@ static int nested_xlate_vsstage(struct nested_xlate_context *xc,
return VMM_OK;
}

static void nested_timer_event_expired(struct vmm_timer_event *ev)
{
/* Do nothing */
}

int cpu_vcpu_nested_init(struct vmm_vcpu *vcpu)
{
int rc;
struct vmm_timer_event *event;
u32 pgtbl_attr = 0, pgtbl_hw_tag = 0;
struct riscv_priv_nested *npriv = riscv_nested_priv(vcpu);

event = vmm_zalloc(sizeof(struct vmm_timer_event));
if (!event) {
return VMM_ENOMEM;
}
INIT_TIMER_EVENT(event, nested_timer_event_expired, vcpu);
npriv->timer_event = event;

if (riscv_stage2_vmid_available()) {
pgtbl_hw_tag = riscv_stage2_vmid_nested + vcpu->guest->id;
pgtbl_attr |= MMU_ATTR_HW_TAG_VALID;
}
npriv->pgtbl = mmu_pgtbl_alloc(MMU_STAGE2, -1, pgtbl_attr,
pgtbl_hw_tag);
if (!npriv->pgtbl) {
vmm_free(npriv->timer_event);
return VMM_ENOMEM;
}

rc = nested_swtlb_init(vcpu);
if (rc) {
mmu_pgtbl_free(npriv->pgtbl);
vmm_free(npriv->timer_event);
return rc;
}

Expand All @@ -840,7 +825,6 @@ void cpu_vcpu_nested_reset(struct vmm_vcpu *vcpu)
{
struct riscv_priv_nested *npriv = riscv_nested_priv(vcpu);

vmm_timer_event_stop(npriv->timer_event);
cpu_vcpu_nested_swtlb_flush(vcpu, 0, 0);
npriv->virt = FALSE;
#ifdef CONFIG_64BIT
Expand Down Expand Up @@ -877,7 +861,6 @@ void cpu_vcpu_nested_deinit(struct vmm_vcpu *vcpu)

nested_swtlb_deinit(vcpu);
mmu_pgtbl_free(npriv->pgtbl);
vmm_free(npriv->timer_event);
}

void cpu_vcpu_nested_dump_regs(struct vmm_chardev *cdev,
Expand Down Expand Up @@ -1788,15 +1771,11 @@ void cpu_vcpu_nested_take_vsirq(struct vmm_vcpu *vcpu,

/*
* If we going to virtual-VS mode and interrupts are disabled
* then start nested timer event.
* then do nothing.
*/
if (next_spp && !(csr_read(CSR_VSSTATUS) & SSTATUS_SIE)) {
if (!vmm_timer_event_pending(npriv->timer_event)) {
vmm_timer_event_start(npriv->timer_event, 10000000);
}
return;
}
vmm_timer_event_stop(npriv->timer_event);

riscv_stats_priv(vcpu)->nested_vsirq++;

Expand Down
2 changes: 0 additions & 2 deletions arch/riscv/cpu/generic/include/arch_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ union riscv_priv_fp {
struct riscv_priv_nested {
/* Nested virt state */
bool virt;
/* Nested interrupts timer event */
void *timer_event;
/* Nested software TLB */
void *swtlb;
/* Nested shadow page table */
Expand Down

0 comments on commit fb46e69

Please sign in to comment.