From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mx.groups.io with SMTP id smtpd.web10.14840.1677235481230799545 for ; Fri, 24 Feb 2023 02:44:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dmqsqt/P; spf=pass (domain: ventanamicro.com, ip: 209.85.210.174, mailfrom: sunilvl@ventanamicro.com) Received: by mail-pf1-f174.google.com with SMTP id z11so273160pfh.4 for ; Fri, 24 Feb 2023 02:44:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B3fDR00bQ+8wgkTyZQ8+XV0nngWn7pDt5BQ3hbUmHXc=; b=dmqsqt/PtTuEKPca1DfbLYV6AnStHEWZb9dTl3bWBl7L00QFa0nUNdQQf84fDaPdRT jUuIoWMjyLUe9W8Zy0Vfj2QBCZGMXLvF/0hJm1ak2nZGfGQxxZLqK2IJGUDycGjxtOKl dhEEA75xxPZXTU8JMd1OCCag19SRo1PO6HT+2sT1wzE+syrYVnVLkmTrXRXcIwO/cZ42 SCXB31h8KTRVDMe87XfDAt7ja8qFCGdT30q1a0WEQjNIo4eIFpBhDBK/Dwbl1y1z/eZ/ XHp3i5Kdj6FPT8SYzoaM0siPheZquJa5N8XKgqULGoKA1HXMYy/QsSrX4Bx3sjVkUeEJ o1nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B3fDR00bQ+8wgkTyZQ8+XV0nngWn7pDt5BQ3hbUmHXc=; b=EmTPLce3zihYFFwRm944BLES5BRpYPgaH/1ckx7rLUrJfk4r0tyzCdQOiXBgkNzlq7 diORJn/t+hTfjnNr+9hj82cTpC0O+vSuyIE91hc6g73CHILPpa2ZqPhxhOC1t9pu9Zn4 CNHFXENPi0fduNu+iITKn7lhy8UBq8ZJyYym6d4dru6rM2PkxmFTzJFpglYM9+zIiFAz 5N5frXm7/R2PVzh8cQQ0NGRRDettoOs2dcM5uTr+G9bekhrR0TRMCv5xsG4SnwOegCIG uppKuomvC3YGBUJnRvAANxa3vndcMwItaqUSZyZ8CQmsyGOMr0FMxymkICdDtTyyskw+ G/qw== X-Gm-Message-State: AO0yUKVGvi37Z5Q4ZrxfG3bxYkaBwn8CzOxB4gO2MZh1wkc1TwiHxB+w C5D58/+AMvAGSJ7Eybx+ZUgXlA== X-Google-Smtp-Source: AK7set80k/xmfy0rqftkfYbXgc5EXfcqp7o66qHrmej/E3/tL3OdsdwWJgkAbuU8GReIAijwcJEC9Q== X-Received: by 2002:aa7:9599:0:b0:5a8:ba74:7a7b with SMTP id z25-20020aa79599000000b005a8ba747a7bmr14036497pfj.1.1677235480599; Fri, 24 Feb 2023 02:44:40 -0800 (PST) Return-Path: Received: from sunil-laptop ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id v10-20020a62ac0a000000b005a817f72c21sm5277210pfe.131.2023.02.24.02.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 02:44:40 -0800 (PST) Date: Fri, 24 Feb 2023 16:14:35 +0530 From: "Sunil V L" To: Andrei Warkentin Cc: devel@edk2.groups.io, Daniel Schaefer Subject: Re: [PATCH 7/7] [PATCH v2] UefiCpuPkg: BaseRiscV64CpuExceptionHandlerLib: clean up exception handling Message-ID: References: <20230223235454.23556-1-andrei.warkentin@intel.com> <20230223235454.23556-8-andrei.warkentin@intel.com> MIME-Version: 1.0 In-Reply-To: <20230223235454.23556-8-andrei.warkentin@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 23, 2023 at 05:54:54PM -0600, Andrei Warkentin wrote: > RegisterCpuInterruptHandler did not allow setting > exception handlers for anything beyond the timer IRQ. > Beyond that, it didn't meet the spec around handling > of inputs. > > RiscVSupervisorModeTrapHandler now will invoke > set handlers for both exceptions and interrupts. > Two arrays of handlers are maintained - one for exceptions > and one for interrupts. > > For unhandled traps, RiscVSupervisorModeTrapHandler dumps > state using the now implemented DumpCpuContext. > > For EFI_SYSTEM_CONTEXT_RISCV64, extend this with the trapped > PC address (SEPC), just like on AArch64 (ELR). This is > necessary for X86EmulatorPkg to work as it allows a trap > handler to return execution to a different place. Add > SSTATUS/STVAL as well, at least for debugging purposes. There > is no value in hiding this. > > Fix nested exception handling. Handler code should not > be saving SIE (the value is saved in SSTATUS.SPIE) or > directly restored (that's done by SRET). Save and > restore the entire SSTATUS and STVAL, too. > > Cc: Sunil V L > Cc: Daniel Schaefer > Signed-off-by: Andrei Warkentin > --- > MdePkg/Include/Protocol/DebugSupport.h | 32 ++- > .../CpuExceptionHandlerLib.h | 11 +- > UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 6 +- > .../CpuExceptionHandlerLib.c | 232 ++++++++++++++++-- > .../SupervisorTrapHandler.S | 17 +- > 5 files changed, 254 insertions(+), 44 deletions(-) > Reviewed-by: Sunil V L