[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 14/15] s390x: protvirt: Disable address checks for PV guest I
From: |
Thomas Huth |
Subject: |
Re: [PATCH 14/15] s390x: protvirt: Disable address checks for PV guest IO emulation |
Date: |
Thu, 28 Nov 2019 21:08:45 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
On 28/11/2019 17.10, Janosch Frank wrote:
> On 11/28/19 4:28 PM, Thomas Huth wrote:
>> On 20/11/2019 12.43, Janosch Frank wrote:
>>> IO instruction data is routed through SIDAD for protected guests, so
>>> adresses do not need to be checked, as this is kernel memory.
>>>
>>> Signed-off-by: Janosch Frank <address@hidden>
>>> ---
>>> target/s390x/ioinst.c | 46 +++++++++++++++++++++++++++----------------
>>> 1 file changed, 29 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c
>>> index c437a1d8c6..d3bd422ddd 100644
>>> --- a/target/s390x/ioinst.c
>>> +++ b/target/s390x/ioinst.c
>>> @@ -110,11 +110,13 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1,
>>> uint32_t ipb, uintptr_t ra)
>>> int cssid, ssid, schid, m;
>>> SubchDev *sch;
>>> SCHIB schib;
>>> - uint64_t addr;
>>> + uint64_t addr = 0;
>>> CPUS390XState *env = &cpu->env;
>>> - uint8_t ar;
>>> + uint8_t ar = 0;
>>>
>>> - addr = decode_basedisp_s(env, ipb, &ar);
>>> + if (!env->pv) {
>>> + addr = decode_basedisp_s(env, ipb, &ar);
>>> + }
>>> if (addr & 3) {
>>> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
>>> return;
>>> @@ -167,11 +169,13 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1,
>>> uint32_t ipb, uintptr_t ra)
>>> int cssid, ssid, schid, m;
>>> SubchDev *sch;
>>> ORB orig_orb, orb;
>>> - uint64_t addr;
>>> + uint64_t addr = 0;
>>> CPUS390XState *env = &cpu->env;
>>> - uint8_t ar;
>>> + uint8_t ar = 0;
>>>
>>> - addr = decode_basedisp_s(env, ipb, &ar);
>>> + if (!env->pv) {
>>> + addr = decode_basedisp_s(env, ipb, &ar);
>>> + }
>>> if (addr & 3) {
>>> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
>>> return;
>>> @@ -198,12 +202,14 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1,
>>> uint32_t ipb, uintptr_t ra)
>>> void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
>>> {
>>> CRW crw;
>>> - uint64_t addr;
>>> + uint64_t addr = 0;
>>> int cc;
>>> CPUS390XState *env = &cpu->env;
>>> - uint8_t ar;
>>> + uint8_t ar = 0;
>>>
>>> - addr = decode_basedisp_s(env, ipb, &ar);
>>> + if (!env->pv) {
>>> + addr = decode_basedisp_s(env, ipb, &ar);
>>> + }
>>> if (addr & 3) {
>>> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
>>> return;
>>> @@ -228,13 +234,15 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1,
>>> uint32_t ipb,
>>> {
>>> int cssid, ssid, schid, m;
>>> SubchDev *sch;
>>> - uint64_t addr;
>>> + uint64_t addr = 0;
>>> int cc;
>>> SCHIB schib;
>>> CPUS390XState *env = &cpu->env;
>>> - uint8_t ar;
>>> + uint8_t ar = 0;
>>>
>>> - addr = decode_basedisp_s(env, ipb, &ar);
>>> + if (!env->pv) {
>>> + addr = decode_basedisp_s(env, ipb, &ar);
>>> + }
>>> if (addr & 3) {
>>> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
>>> return;
>>> @@ -294,16 +302,18 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1,
>>> uint32_t ipb, uintptr_t ra)
>>> int cssid, ssid, schid, m;
>>> SubchDev *sch;
>>> IRB irb;
>>> - uint64_t addr;
>>> + uint64_t addr = 0;
>>> int cc, irb_len;
>>> - uint8_t ar;
>>> + uint8_t ar = 0;
>>>
>>> if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
>>> s390_program_interrupt(env, PGM_OPERAND, ra);
>>> return -EIO;
>>> }
>>> trace_ioinst_sch_id("tsch", cssid, ssid, schid);
>>> - addr = decode_basedisp_s(env, ipb, &ar);
>>> + if (!env->pv) {
>>> + addr = decode_basedisp_s(env, ipb, &ar);
>>> + }
>>> if (addr & 3) {
>>> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
>>> return -EIO;
>>
>> Would it make sense to hide all these changes in decode_basedisp_s()
>> instead? ... so that decode_basedisp_s() returns 0 if env->pv == true ?
>> ... or are there still cases where we need real values from
>> decode_basedisp_s() in case of env->pv==true?
>
> I'd like to keep decode_basedisp_s() as is, but how about a static
> function in ioinst.c called something like get_address_from_regs()?
>
> It'll call decode_basedisp_s() or return 0.
Sounds fine for me, too!
Thomas
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH 09/15] s390x: protvirt: SCLP interpretation, (continued)
[PATCH 10/15] s390x: protvirt: Add new VCPU reset functions, Janosch Frank, 2019/11/20
[PATCH 13/15] s390x: protvirt: Move diag 308 data over SIDAD, Janosch Frank, 2019/11/20
[PATCH 15/15] s390x: protvirt: Handle SIGP store status correctly, Janosch Frank, 2019/11/20
[PATCH 11/15] RFC: s390x: Exit on vcpu reset error, Janosch Frank, 2019/11/20