Skip to content

Commit aee9f3c

Browse files
ZideChen0wenlingz
authored andcommitted
hv: reset per cpu sbuf pointers during vcpu reset
When shutting down SOS VM, the shared sbuf is released from guest OS, but the per cpu sbuf pointers in hypervisor keep inact. This creates a problem that after SOS is re-launched, hypervisor could write to the shared buffer that no longer exists. This patch implements sbuf_reset() and call it from reset_vcpu() to reset sbuf pointers. Tracked-On: #2700 Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 56acaac commit aee9f3c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ void reset_vcpu(struct acrn_vcpu *vcpu)
582582
vlapic = vcpu_vlapic(vcpu);
583583
vlapic_reset(vlapic);
584584

585+
sbuf_reset(vcpu->pcpu_id);
586+
585587
reset_vcpu_regs(vcpu);
586588
}
587589

hypervisor/debug/sbuf.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,14 @@ int32_t sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva)
121121

122122
return 0;
123123
}
124+
125+
void sbuf_reset(uint16_t pcpu_id)
126+
{
127+
uint32_t sbuf_id;
128+
129+
if (pcpu_id < get_pcpu_nums()) {
130+
for (sbuf_id = 0U; sbuf_id < ACRN_SBUF_ID_MAX; sbuf_id++) {
131+
per_cpu(sbuf, pcpu_id)[sbuf_id] = 0U;
132+
}
133+
}
134+
}

hypervisor/include/debug/sbuf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct shared_buf {
6565
*/
6666
uint32_t sbuf_put(struct shared_buf *sbuf, uint8_t *data);
6767
int32_t sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva);
68+
void sbuf_reset(uint16_t pcpu_id);
6869
uint32_t sbuf_next_ptr(uint32_t pos, uint32_t span, uint32_t scope);
6970

7071
#endif /* SHARED_BUFFER_H */

hypervisor/release/sbuf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <types.h>
8+
#include <sbuf.h>
9+
10+
void sbuf_reset(__unused uint16_t pcpu_id) {}

0 commit comments

Comments
 (0)