Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F112076039
D48829.id150525.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D48829.id150525.diff
View Options
diff --git a/usr.sbin/bhyve/riscv/vmexit.c b/usr.sbin/bhyve/riscv/vmexit.c
--- a/usr.sbin/bhyve/riscv/vmexit.c
+++ b/usr.sbin/bhyve/riscv/vmexit.c
@@ -173,13 +173,7 @@
return (1);
}
-static void
-vmexit_ecall_time(struct vmctx *ctx __unused, struct vm_exit *vme __unused)
-{
-
-}
-
-static void
+static int
vmexit_ecall_hsm(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
struct vm_exit *vme)
{
@@ -187,15 +181,12 @@
uint64_t hart_id;
int func_id;
int error;
- int ret;
hart_id = vme->u.ecall.args[0];
func_id = vme->u.ecall.args[6];
- ret = -1;
-
if (HART_TO_CPU(hart_id) >= (uint64_t)guest_ncpus)
- goto done;
+ return (SBI_ERR_INVALID_PARAM);
newvcpu = fbsdrun_vcpu(HART_TO_CPU(hart_id));
assert(newvcpu != NULL);
@@ -221,42 +212,34 @@
vm_resume_cpu(newvcpu);
CPU_SET_ATOMIC(hart_id, &running_hartmask);
-
- ret = 0;
break;
case SBI_HSM_HART_STOP:
if (!CPU_ISSET(hart_id, &running_hartmask))
break;
CPU_CLR_ATOMIC(hart_id, &running_hartmask);
vm_suspend_cpu(newvcpu);
- ret = 0;
break;
case SBI_HSM_HART_STATUS:
/* TODO. */
break;
default:
- break;
+ return (SBI_ERR_NOT_SUPPORTED);
}
-done:
- error = vm_set_register(vcpu, VM_REG_GUEST_A0, ret);
- assert(error == 0);
+ return (SBI_SUCCESS);
}
-static void
+static int
vmexit_ecall_base(struct vmctx *ctx __unused, struct vcpu *vcpu,
struct vm_exit *vme)
{
int sbi_function_id;
+ uint32_t val;
int ext_id;
int error;
- uint32_t val;
- int ret;
sbi_function_id = vme->u.ecall.args[6];
- ret = 0;
-
switch (sbi_function_id) {
case SBI_BASE_GET_SPEC_VERSION:
val = SBI_VERS_MAJOR << SBI_SPEC_VERS_MAJOR_OFFSET;
@@ -282,20 +265,16 @@
val = 0;
break;
default:
- ret = 1;
- break;
+ return (SBI_ERR_NOT_SUPPORTED);
}
- error = vm_set_register(vcpu, VM_REG_GUEST_A0, ret);
+ error = vm_set_register(vcpu, VM_REG_GUEST_A1, val);
assert(error == 0);
- if (ret == 0) {
- error = vm_set_register(vcpu, VM_REG_GUEST_A1, val);
- assert(error == 0);
- }
+ return (SBI_SUCCESS);
}
-static void
+static int
vmexit_ecall_srst(struct vmctx *ctx, struct vm_exit *vme)
{
enum vm_suspend_how how;
@@ -315,11 +294,14 @@
vm_suspend(ctx, how);
break;
default:
- break;
+ return (SBI_ERR_NOT_SUPPORTED);
}
- default:
break;
+ default:
+ return (SBI_ERR_NOT_SUPPORTED);
}
+
+ return (SBI_SUCCESS);
}
static int
@@ -327,30 +309,33 @@
{
int sbi_extension_id;
struct vm_exit *vme;
+ int error;
+ int ret;
vme = vmrun->vm_exit;
sbi_extension_id = vme->u.ecall.args[7];
switch (sbi_extension_id) {
case SBI_EXT_ID_SRST:
- vmexit_ecall_srst(ctx, vme);
+ ret = vmexit_ecall_srst(ctx, vme);
break;
case SBI_EXT_ID_BASE:
- vmexit_ecall_base(ctx, vcpu, vme);
- break;
- case SBI_EXT_ID_TIME:
- vmexit_ecall_time(ctx, vme);
+ ret = vmexit_ecall_base(ctx, vcpu, vme);
break;
case SBI_EXT_ID_HSM:
- vmexit_ecall_hsm(ctx, vcpu, vme);
+ ret = vmexit_ecall_hsm(ctx, vcpu, vme);
break;
case SBI_CONSOLE_PUTCHAR:
case SBI_CONSOLE_GETCHAR:
default:
/* Unknown SBI extension. */
+ ret = SBI_ERR_NOT_SUPPORTED;
break;
}
+ error = vm_set_register(vcpu, VM_REG_GUEST_A0, ret);
+ assert(error == 0);
+
return (VMEXIT_CONTINUE);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 13, 11:46 AM (17 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16473971
Default Alt Text
D48829.id150525.diff (3 KB)
Attached To
Mode
D48829: bhyve/riscv: clean up SBI handlers
Attached
Detach File
Event Timeline
Log In to Comment