-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify and generalize host control of machine #257
Comments
After some thought, here is a possibility. A machine is halted if We change the part of the interpret loop that checks for fixed-point yield/halt to the following:
We change the HTIF protocol to be as follows: From the inside, to use HTIF, guest code writes dev+cmd+data to We also change |
This comment has been minimized.
This comment has been minimized.
Hey @stskeeps, we are thinking of following this idea (or some refinement of it) on the release after the next one. Do you have reservations? @GCdePaula? @vfusco @mpolitzer |
What you described seem to be the current behavior from the guest POV on yield[1]. Is that so? would there be any required changes in: opensbi, linux or libcmt? Seems close to the current workflow on the host side. I don't se an issue there. |
I think we can do further than what I suggested above. Right now, we have DEV/CMD/(REASON/DATA). This seems to be very overkill. We should perhaps have CMD(16)/DATA(48) and be done with it? With new CMD getting the current DEV/CMD/REASON. Or some other simpler division. Also remove the LSB requirement from HALT, which is also overkill. If you issue a HALT, you are halted. :) |
I'm down for simplification, I don't mind updating our code. I'm trying to understand the changes. Would this remove the possibility of querying "what was the latest break reason"? Like, it seems it's currently possible to look only at the current state of the machine and know what was the reason the machine broke last.
What would be the possible values for CMD in this proposal? In the case of
And the
Why do we need both |
Also, do we need both halt and yield? |
The break reason would still be visible in tohost/mcycle. |
Context
Controlling a machine engaged with rollups involves reading and writing to a bunch of different machine CSRs. The introduction of the
send_cmio_response
simplified, but it is still complicated.run
now returns thebreak_reason
, which simplifies it further. But now there are unnecessary redundancies that may cause confusion.Possible solutions
At the moment,
iflags
has fieldsPRV
and theX
,Y
, andH
flags.PRV
really is something internal that the host should never mess with (the current machine privilege level).Let's promote
iflags.PRV
to its own full CSRiprv
. This will simplify the state-access implementations, since they won't have to do field manipulation there anymore.X
,Y
, andH
, on the other hand, are things the host needs to look at and, in the case ofY
, change.There is never a case in which more than one of these flags is set. They are always set via HTIF from the inside.
In the case of
X
andY
, the host will also need to look intohtif.tohost
. This is becausehtif.tohost
contains thereason
for the yield and the amount of data written totx_buffer
.X
is set when the machine returns from an automatic yield. Let's removeX
altogether, since the machinerun
already returns this as a break reason andX
is cleared automatically.Y
when it returns from a manual yield.H
when it is permanently halted.Let's relocate
Y
andH
tohtif.tohost
. With some reorganization there, we can make this happen.(This will also simplify HTIF implementation, since it won't need to change the iflags register anymore.)
Let's rename
Y
toYM
to make the distinction obvious. It's not a generic yield flag, but rather a Manual Yield flag.Perhaps we can be smart and use the
device+cmd
fields together as "the flag", with a few changes to make them uniquely identify the halt and the manual yields.There already are many
WARL
CSRs that prevent certain bits from being changed.htif.tohost
would be one of these. IfH
is set, it would remain set forever. I think we can even use a write tohtif.fromhost
to clearYM
, saving the need to modifyhtif.tohost
when returning from a manual yield.The text was updated successfully, but these errors were encountered: