mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-08 19:48:58 +00:00
hv:Replace dynamic allocation with static memory for shell
Pre-allocate 2 pages of static memory for shell log buffer. Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
c045442163
commit
3718177687
@ -11,6 +11,8 @@
|
|||||||
#define MAX_STR_SIZE 256U
|
#define MAX_STR_SIZE 256U
|
||||||
#define SHELL_PROMPT_STR "ACRN:\\>"
|
#define SHELL_PROMPT_STR "ACRN:\\>"
|
||||||
|
|
||||||
|
char shell_log_buf[CPU_PAGE_SIZE*2];
|
||||||
|
|
||||||
/* Input Line Other - Switch to the "other" input line (there are only two
|
/* Input Line Other - Switch to the "other" input line (there are only two
|
||||||
* input lines total).
|
* input lines total).
|
||||||
*/
|
*/
|
||||||
@ -624,11 +626,6 @@ static int shell_vcpu_dumpreg(int argc, char **argv)
|
|||||||
struct vcpu *vcpu;
|
struct vcpu *vcpu;
|
||||||
uint64_t mask = 0UL;
|
uint64_t mask = 0UL;
|
||||||
struct vcpu_dump dump;
|
struct vcpu_dump dump;
|
||||||
char *temp_str = alloc_page();
|
|
||||||
|
|
||||||
if (temp_str == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* User input invalidation */
|
/* User input invalidation */
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
@ -662,7 +659,7 @@ static int shell_vcpu_dumpreg(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dump.vcpu = vcpu;
|
dump.vcpu = vcpu;
|
||||||
dump.str = temp_str;
|
dump.str = shell_log_buf;
|
||||||
dump.str_max = CPU_PAGE_SIZE;
|
dump.str_max = CPU_PAGE_SIZE;
|
||||||
if (vcpu->pcpu_id == get_cpu_id())
|
if (vcpu->pcpu_id == get_cpu_id())
|
||||||
vcpu_dumpreg(&dump);
|
vcpu_dumpreg(&dump);
|
||||||
@ -670,12 +667,10 @@ static int shell_vcpu_dumpreg(int argc, char **argv)
|
|||||||
bitmap_set_nolock(vcpu->pcpu_id, &mask);
|
bitmap_set_nolock(vcpu->pcpu_id, &mask);
|
||||||
smp_call_function(mask, vcpu_dumpreg, &dump);
|
smp_call_function(mask, vcpu_dumpreg, &dump);
|
||||||
}
|
}
|
||||||
shell_puts(temp_str);
|
shell_puts(shell_log_buf);
|
||||||
status = 0;
|
status = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(temp_str);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,93 +756,53 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv)
|
|||||||
|
|
||||||
static int shell_show_cpu_int(__unused int argc, __unused char **argv)
|
static int shell_show_cpu_int(__unused int argc, __unused char **argv)
|
||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
get_cpu_interrupt_info(shell_log_buf, CPU_PAGE_SIZE);
|
||||||
|
shell_puts(shell_log_buf);
|
||||||
if (temp_str == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
get_cpu_interrupt_info(temp_str, CPU_PAGE_SIZE);
|
|
||||||
shell_puts(temp_str);
|
|
||||||
|
|
||||||
free(temp_str);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shell_show_ptdev_info(__unused int argc, __unused char **argv)
|
static int shell_show_ptdev_info(__unused int argc, __unused char **argv)
|
||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
get_ptdev_info(shell_log_buf, CPU_PAGE_SIZE);
|
||||||
|
shell_puts(shell_log_buf);
|
||||||
if (temp_str == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
get_ptdev_info(temp_str, CPU_PAGE_SIZE);
|
|
||||||
shell_puts(temp_str);
|
|
||||||
|
|
||||||
free(temp_str);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shell_show_vioapic_info(int argc, char **argv)
|
static int shell_show_vioapic_info(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
|
||||||
uint16_t vmid;
|
uint16_t vmid;
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
if (temp_str == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* User input invalidation */
|
/* User input invalidation */
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
free(temp_str);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
ret = atoi(argv[1]);
|
ret = atoi(argv[1]);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
vmid = (uint16_t) ret;
|
vmid = (uint16_t) ret;
|
||||||
get_vioapic_info(temp_str, CPU_PAGE_SIZE, vmid);
|
get_vioapic_info(shell_log_buf, CPU_PAGE_SIZE, vmid);
|
||||||
shell_puts(temp_str);
|
shell_puts(shell_log_buf);
|
||||||
free(temp_str);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(temp_str);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shell_show_ioapic_info(__unused int argc, __unused char **argv)
|
static int shell_show_ioapic_info(__unused int argc, __unused char **argv)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char *temp_str = alloc_pages(2U);
|
|
||||||
|
|
||||||
if (temp_str == NULL) {
|
err = get_ioapic_info(shell_log_buf, 2 * CPU_PAGE_SIZE);
|
||||||
return -ENOMEM;
|
shell_puts(shell_log_buf);
|
||||||
}
|
|
||||||
|
|
||||||
err = get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
|
|
||||||
shell_puts(temp_str);
|
|
||||||
|
|
||||||
free(temp_str);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shell_show_vmexit_profile(__unused int argc, __unused char **argv)
|
static int shell_show_vmexit_profile(__unused int argc, __unused char **argv)
|
||||||
{
|
{
|
||||||
char *temp_str = alloc_pages(2U);
|
get_vmexit_profile(shell_log_buf, 2*CPU_PAGE_SIZE);
|
||||||
|
shell_puts(shell_log_buf);
|
||||||
if (temp_str == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
get_vmexit_profile(temp_str, 2*CPU_PAGE_SIZE);
|
|
||||||
shell_puts(temp_str);
|
|
||||||
|
|
||||||
free(temp_str);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user