Skip to content

Commit 87ac1a6

Browse files
committed
debug: remove handle_db_exception
handle_db_exception was only used in the SVSM #VC handler. This function was calling handle_debug_exception under the hood. We can remove handle_db_exception and integreate its logic into handle_debug_exception so that it remains only 1 debug exception handling function. Signed-off-by: Thomas Leroy <[email protected]>
1 parent bb184f7 commit 87ac1a6

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/cpu/vc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::idt::common::X86ExceptionContext;
88
use crate::cpu::cpuid::{cpuid_table_raw, CpuidLeaf};
99
use crate::cpu::insn::{insn_fetch, Instruction};
1010
use crate::cpu::percpu::this_cpu_mut;
11-
use crate::debug::gdbstub::svsm_gdbstub::handle_db_exception;
11+
use crate::debug::gdbstub::svsm_gdbstub::handle_debug_exception;
1212
use crate::error::SvsmError;
1313
use crate::sev::ghcb::{GHCBIOSize, GHCB};
1414
use core::fmt;
@@ -128,7 +128,7 @@ pub fn handle_vc_exception(ctx: &mut X86ExceptionContext) {
128128
match error_code {
129129
// If the debugger is enabled then handle the DB exception
130130
// by directly invoking the exception handler
131-
X86_TRAP_DB => handle_db_exception(ctx),
131+
X86_TRAP_DB => handle_debug_exception(ctx, ctx.vector),
132132
SVM_EXIT_CPUID => handle_cpuid(ctx).expect("Could not handle CPUID #VC exception"),
133133
SVM_EXIT_IOIO => {
134134
handle_ioio(ctx, ghcb, &insn).expect("Could not handle IOIO #VC exception")

src/debug/gdbstub.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod svsm_gdbstub {
1515

1616
use crate::address::{Address, VirtAddr};
1717
use crate::cpu::control_regs::read_cr3;
18-
use crate::cpu::idt::common::{X86ExceptionContext, BP_VECTOR};
18+
use crate::cpu::idt::common::{X86ExceptionContext, BP_VECTOR, VC_VECTOR};
1919
use crate::cpu::percpu::{this_cpu, this_cpu_mut};
2020
use crate::cpu::X86GeneralRegs;
2121
use crate::error::SvsmError;
@@ -72,15 +72,12 @@ pub mod svsm_gdbstub {
7272
pub fn handle_debug_exception(ctx: &mut X86ExceptionContext, exception: usize) {
7373
let tp = match exception {
7474
BP_VECTOR => ExceptionType::SwBreakpoint,
75+
VC_VECTOR => ExceptionType::Debug,
7576
_ => ExceptionType::PageFault,
7677
};
7778
handle_exception(ctx, tp);
7879
}
7980

80-
pub fn handle_db_exception(ctx: &mut X86ExceptionContext) {
81-
handle_exception(ctx, ExceptionType::Debug);
82-
}
83-
8481
fn handle_exception(ctx: &mut X86ExceptionContext, exception_type: ExceptionType) {
8582
let id = this_cpu().runqueue().lock_read().current_task_id();
8683
let mut task_ctx = TaskContext {

0 commit comments

Comments
 (0)