Quetion about xRET instruction


Oscar Jupp
 


Dear architect, 
The spec section 3.3.2 said:
An xRET instruction can be executed in privilege mode x or higher, where executing a lower-privilege xRET instruction will pop the relevant lower-privilege interrupt enable and privilege mode stack.”
It's not clear to me what is the application scenario for doing this?
Why execute a SRET instruction in M-mode?
Just change SIE, SPIE, SPP? Need to change privileged mode and other CSRs?

Regards,
Oscar Jupp


Ved Shanbhogue
 

The ability to execute SRET in M-mode provides M-mode the
facility to trap, using TSR control, a SRET invoked in S-mode,
and after handling the trap to redo the SRET. The SRET invoked
in M-mode is not affected by the TSR control.

regards
ved

On Fri, Dec 02, 2022 at 08:33:51PM +0800, Oscar Jupp wrote:
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
</head>
<body>
<style>
font{
line-height: 1.6;
}
ul,ol{
padding-left: 20px;
list-style-position: inside;
}
</style>
<div style = 'font-family:Helvetica,Helvetica,微软雅黑, 宋体; line-height:1.6;'>
<div ></div><div>
<div>
<span>
<br>
</span>
</div>
<div>
<span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Dear&nbsp;architect,&nbsp;</span></div><div><font face="Helvetica, Helvetica, 微软雅黑, 宋体">The spec section&nbsp;</font>3.3.2&nbsp;<span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">said:</span></div><div><span>“</span>An xRET instruction can be executed in privilege mode x or higher, where executing a lower-privilege xRET instruction will pop the relevant lower-privilege interrupt enable and privilege mode stack.”</div><div>It's not clear to me what is the application scenario for doing this?<br>Why execute a SRET instruction in M-mode?<span><br></span></div><div>Just change SIE, SPIE, SPP? Need to change privileged mode and other CSRs?<br></div><div><span><br></span></div><div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Regards,</div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Oscar Jupp</div></div>
<div id="ntes-pcmac-signature" style="font-family:'Helvetica','Microsoft Yahei', '微软雅黑'">
<div style="font-size:14px; padding: 0; margin:0;line-height: 14px;">
<div style="padding-bottom:6px;margin-bottom:10px;display:inline-block;">
<a href="https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=1&;name=jupposcar&amp;uid=jupposcar%40gmail.com&amp;iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fqiyelogo%2FdefaultAvatar.png&amp;items=%5B%22jupposcar%40gmail.com%22%5D" style="display:block;background:#fff; max-width: 400px; _width: 400px;padding:15px 0 10px 0;text-decoration: none; outline:none;-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<table cellpadding="0" style="width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse;color: #9b9ea1;font-size: 14px;line-height:1.3;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tbody style="font-family: 'PingFang SC', 'Hiragino Sans GB','WenQuanYi Micro Hei', 'Microsoft Yahei', '微软雅黑', verdana !important; word-wrap:break-word; word-break:break-all;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tr class="firstRow">
<td width="38" style="padding:0; box-sizing: border-box; width: 38px;">
<img width="38" height="38" style="vertical-align:middle; width: 38px; height: 38px; border-radius:50%;" src="https://mail-online.nosdn.127.net/qiyelogo/defaultAvatar.png">
</td>
<td style="padding: 0 0 0 10px; color: #31353b;">
<div style="font-size: 16px;font-weight:bold; width:100%; white-space: nowrap; overflow:hidden;text-overflow: ellipsis;">jupposcar</div>
</td>
</tr>
<tr width="100%" style="font-size: 14px !important; width: 100%;">
<td colspan="2" style="padding:10px 0 0 0; font-size:14px !important; width: 100%;">
<div style="width: 100%;font-size: 14px !important;word-wrap:break-word;word-break:break-all;">jupposcar@...</div>
</td>
</tr>
</tbody>
</table>
</a>
</div>
</div>
</div>
<br>
</div><!--�-->
</div>
</body>
</html>

<div width="1" style="color:white;clear:both"></div>


Allen Baum
 

I first read this as TSR meaning "Trap Service Routine", 
but now I understand that it is the mstatus.TSR bit.


On Fri, Dec 2, 2022 at 5:21 AM Ved Shanbhogue <ved@...> wrote:
The ability to execute SRET in M-mode provides M-mode the
facility to trap, using TSR control, a SRET invoked in S-mode,
and after handling the trap to redo the SRET. The SRET invoked
in M-mode is not affected by the TSR control.

regards
ved



On Fri, Dec 02, 2022 at 08:33:51PM +0800, Oscar Jupp wrote:
><html>
><head>
>    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
></head>
><body>
><style>
>    font{
>        line-height: 1.6;
>    }
>    ul,ol{
>        padding-left: 20px;
>        list-style-position: inside;
>    }
></style>
><div style = 'font-family:Helvetica,Helvetica,微软雅黑, 宋体; line-height:1.6;'>
>    <div ></div><div>
>    <div>
>        <span>
>            <br>
>        </span>
>    </div>
>    <div>
>        <span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Dear&nbsp;architect,&nbsp;</span></div><div><font face="Helvetica, Helvetica, 微软雅黑, 宋体">The spec section&nbsp;</font>3.3.2&nbsp;<span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">said:</span></div><div><span>“</span>An xRET instruction can be executed in privilege mode x or higher, where executing a lower-privilege xRET instruction will pop the relevant lower-privilege interrupt enable and privilege mode stack.”</div><div>It's not clear to me what is the application scenario for doing this?<br>Why execute a SRET instruction in M-mode?<span><br></span></div><div>Just change SIE, SPIE, SPP? Need to change privileged mode and other CSRs?<br></div><div><span><br></span></div><div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Regards,</div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Oscar Jupp</div></div>
>    <div id="ntes-pcmac-signature" style="font-family:'Helvetica','Microsoft Yahei', '微软雅黑'">
>     
>    <div style="font-size:14px; padding: 0;  margin:0;line-height: 14px;">
>        <div style="padding-bottom:6px;margin-bottom:10px;display:inline-block;">
>                    <a href="https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=1&amp;name=jupposcar&amp;uid=jupposcar%40gmail.com&amp;iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fqiyelogo%2FdefaultAvatar.png&amp;items=%5B%22jupposcar%40gmail.com%22%5D" style="display:block;background:#fff; max-width: 400px; _width: 400px;padding:15px 0 10px 0;text-decoration: none; outline:none;-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
>            <table cellpadding="0" style="width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse;color: #9b9ea1;font-size: 14px;line-height:1.3;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
>                <tbody style="font-family: 'PingFang SC', 'Hiragino Sans GB','WenQuanYi Micro Hei', 'Microsoft Yahei', '微软雅黑', verdana !important; word-wrap:break-word; word-break:break-all;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
>                    <tr class="firstRow">
>                            <td width="38" style="padding:0; box-sizing: border-box; width: 38px;">
>                                <img width="38" height="38" style="vertical-align:middle; width: 38px; height: 38px; border-radius:50%;" src="https://mail-online.nosdn.127.net/qiyelogo/defaultAvatar.png">
>                            </td>
>                            <td style="padding: 0 0 0 10px; color: #31353b;">
>                                <div style="font-size: 16px;font-weight:bold; width:100%; white-space: nowrap; overflow:hidden;text-overflow: ellipsis;">jupposcar</div>
>                            </td>
>                    </tr>
>                        <tr width="100%" style="font-size: 14px !important; width: 100%;">
>                            <td colspan="2" style="padding:10px 0 0 0; font-size:14px !important; width: 100%;">
>                                    <div style="width: 100%;font-size: 14px !important;word-wrap:break-word;word-break:break-all;">jupposcar@...</div>
>                            </td>
>                        </tr>
>                </tbody>
>            </table>
>        </a>
>        </div>
>    </div>
> </div>
>    <br>
></div><!--�-->
></div>
></body>
></html>
>
> <div width="1" style="color:white;clear:both"></div>
>






Oscar Jupp
 

Dear architect,
Thank you for your reply.
I wonder how to emulate the hypervisor extension with trapping SRET on implementations that do not provide it.

Regards,
Oscar Jupp


---- Replied Message ----
From Ved Shanbhogue<ved@...>
Date 12/2/2022 21:21
To Oscar Jupp<jupposcar@...>
Cc tech-privileged@...<tech-privileged@...>
Subject Re: [RISC-V] [tech-privileged] Quetion about xRET instruction
The ability to execute SRET in M-mode provides M-mode the
facility to trap, using TSR control, a SRET invoked in S-mode,
and after handling the trap to redo the SRET. The SRET invoked
in M-mode is not affected by the TSR control.

regards
ved



On Fri, Dec 02, 2022 at 08:33:51PM +0800, Oscar Jupp wrote:
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
</head>
<body>
<style>
font{
line-height: 1.6;
}
ul,ol{
padding-left: 20px;
list-style-position: inside;
}
</style>
<div style = 'font-family:Helvetica,Helvetica,微软雅黑, 宋体; line-height:1.6;'>
<div ></div><div>
<div>
<span>
<br>
</span>
</div>
<div>
<span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Dear&nbsp;architect,&nbsp;</span></div><div><font face="Helvetica, Helvetica, 微软雅黑, 宋体">The spec section&nbsp;</font>3.3.2&nbsp;<span style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">said:</span></div><div><span>“</span>An xRET instruction can be executed in privilege mode x or higher, where executing a lower-privilege xRET instruction will pop the relevant lower-privilege interrupt enable and privilege mode stack.”</div><div>It's not clear to me what is the application scenario for doing this?<br>Why execute a SRET instruction in M-mode?<span><br></span></div><div>Just change SIE, SPIE, SPP? Need to change privileged mode and other CSRs?<br></div><div><span><br></span></div><div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Regards,</div><div style="font-family: Helvetica, Helvetica, 微软雅黑, 宋体;">Oscar Jupp</div></div>
<div id="ntes-pcmac-signature" style="font-family:'Helvetica','Microsoft Yahei', '微软雅黑'">

<div style="font-size:14px; padding: 0;  margin:0;line-height: 14px;">
<div style="padding-bottom:6px;margin-bottom:10px;display:inline-block;">
<a href="https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=1&amp;name=jupposcar&amp;uid=jupposcar%40gmail.com&amp;iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fqiyelogo%2FdefaultAvatar.png&amp;items=%5B%22jupposcar%40gmail.com%22%5D" style="display:block;background:#fff; max-width: 400px; _width: 400px;padding:15px 0 10px 0;text-decoration: none; outline:none;-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<table cellpadding="0" style="width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse;color: #9b9ea1;font-size: 14px;line-height:1.3;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tbody style="font-family: 'PingFang SC', 'Hiragino Sans GB','WenQuanYi Micro Hei', 'Microsoft Yahei', '微软雅黑', verdana !important; word-wrap:break-word; word-break:break-all;-webkit-text-size-adjust:none !important;text-size-adjust:none !important;">
<tr class="firstRow">
<td width="38" style="padding:0; box-sizing: border-box; width: 38px;">
<img width="38" height="38" style="vertical-align:middle; width: 38px; height: 38px; border-radius:50%;" src="https://mail-online.nosdn.127.net/qiyelogo/defaultAvatar.png">
</td>
<td style="padding: 0 0 0 10px; color: #31353b;">
<div style="font-size: 16px;font-weight:bold; width:100%; white-space: nowrap; overflow:hidden;text-overflow: ellipsis;">jupposcar</div>
</td>
</tr>
<tr width="100%" style="font-size: 14px !important; width: 100%;">
<td colspan="2" style="padding:10px 0 0 0; font-size:14px !important; width: 100%;">
<div style="width: 100%;font-size: 14px !important;word-wrap:break-word;word-break:break-all;">jupposcar@...</div>
</td>
</tr>
</tbody>
</table>
</a>
</div>
</div>
</div>
<br>
</div><!--�-->
</div>
</body>
</html>