diff mbox series

[1/2] pc-bios: s390x: Ensure Read IPL memory is clean

Message ID 20201119165729.63351-2-farman@linux.ibm.com
State New
Headers show
Series pc-bios/s390 fixes for reboot-to-vfio-ccw | expand

Commit Message

Eric Farman Nov. 19, 2020, 4:57 p.m. UTC
If, for example, we boot off a virtio device and chreipl to a vfio-ccw
device, the space at lowcore will be non-zero. We build a Read IPL CCW
at address zero, but it will have leftover PSW data that will conflict
with the Format-0 CCW being generated:

0x0: 00080000 80010000
       ------ Ccw0.cda
              -- Ccw0.chainData
                -- Reserved bits

The data address will be overwritten with the correct value (0x0), but
the apparent data chain bit will cause subsequent memory to be used as
the target of the data store, which may not be where we expect (0x0).

Clear out this space when we boot from DASD, so that we know it exists
exactly as we expect.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 pc-bios/s390-ccw/dasd-ipl.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Thomas Huth Nov. 19, 2020, 8:06 p.m. UTC | #1
On 19/11/2020 17.57, Eric Farman wrote:
> If, for example, we boot off a virtio device and chreipl to a vfio-ccw
> device, the space at lowcore will be non-zero. We build a Read IPL CCW
> at address zero, but it will have leftover PSW data that will conflict
> with the Format-0 CCW being generated:
> 
> 0x0: 00080000 80010000
>        ------ Ccw0.cda
>               -- Ccw0.chainData
>                 -- Reserved bits
> 
> The data address will be overwritten with the correct value (0x0), but
> the apparent data chain bit will cause subsequent memory to be used as
> the target of the data store, which may not be where we expect (0x0).
> 
> Clear out this space when we boot from DASD, so that we know it exists
> exactly as we expect.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  pc-bios/s390-ccw/dasd-ipl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
> index 0fc879bb8e..71cbae2f16 100644
> --- a/pc-bios/s390-ccw/dasd-ipl.c
> +++ b/pc-bios/s390-ccw/dasd-ipl.c
> @@ -100,6 +100,9 @@ static void make_readipl(void)
>  {
>      Ccw0 *ccwIplRead = (Ccw0 *)0x00;
>  
> +    /* Clear out any existing data */
> +    memset(ccwIplRead, 0, sizeof(Ccw0));
> +
>      /* Create Read IPL ccw at address 0 */
>      ccwIplRead->cmd_code = CCW_CMD_READ_IPL;
>      ccwIplRead->cda = 0x00; /* Read into address 0x00 in main memory */

Sounds reasonable.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Janosch Frank Nov. 20, 2020, 8:26 a.m. UTC | #2
On 11/19/20 5:57 PM, Eric Farman wrote:
> If, for example, we boot off a virtio device and chreipl to a vfio-ccw
> device, the space at lowcore will be non-zero. We build a Read IPL CCW
> at address zero, but it will have leftover PSW data that will conflict
> with the Format-0 CCW being generated:
> 
> 0x0: 00080000 80010000
>        ------ Ccw0.cda
>               -- Ccw0.chainData
>                 -- Reserved bits
> 
> The data address will be overwritten with the correct value (0x0), but
> the apparent data chain bit will cause subsequent memory to be used as
> the target of the data store, which may not be where we expect (0x0).
> 
> Clear out this space when we boot from DASD, so that we know it exists
> exactly as we expect.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

Seems like I should have been more specific with my LGTM:
Reviewed-by: Janosch Frank <frankja@de.ibm.com>

> ---
>  pc-bios/s390-ccw/dasd-ipl.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
> index 0fc879bb8e..71cbae2f16 100644
> --- a/pc-bios/s390-ccw/dasd-ipl.c
> +++ b/pc-bios/s390-ccw/dasd-ipl.c
> @@ -100,6 +100,9 @@ static void make_readipl(void)
>  {
>      Ccw0 *ccwIplRead = (Ccw0 *)0x00;
>  
> +    /* Clear out any existing data */
> +    memset(ccwIplRead, 0, sizeof(Ccw0));
> +
>      /* Create Read IPL ccw at address 0 */
>      ccwIplRead->cmd_code = CCW_CMD_READ_IPL;
>      ccwIplRead->cda = 0x00; /* Read into address 0x00 in main memory */
>
Cornelia Huck Nov. 20, 2020, 9:26 a.m. UTC | #3
On Thu, 19 Nov 2020 17:57:28 +0100
Eric Farman <farman@linux.ibm.com> wrote:

> If, for example, we boot off a virtio device and chreipl to a vfio-ccw
> device, the space at lowcore will be non-zero. We build a Read IPL CCW
> at address zero, but it will have leftover PSW data that will conflict
> with the Format-0 CCW being generated:
> 
> 0x0: 00080000 80010000
>        ------ Ccw0.cda
>               -- Ccw0.chainData
>                 -- Reserved bits
> 
> The data address will be overwritten with the correct value (0x0), but
> the apparent data chain bit will cause subsequent memory to be used as
> the target of the data store, which may not be where we expect (0x0).
> 
> Clear out this space when we boot from DASD, so that we know it exists
> exactly as we expect.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  pc-bios/s390-ccw/dasd-ipl.c | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Cornelia Huck <cohuck@redhat.com>
Eric Farman Nov. 20, 2020, 2:39 p.m. UTC | #4
On 11/20/20 3:26 AM, Janosch Frank wrote:
> On 11/19/20 5:57 PM, Eric Farman wrote:
>> If, for example, we boot off a virtio device and chreipl to a vfio-ccw
>> device, the space at lowcore will be non-zero. We build a Read IPL CCW
>> at address zero, but it will have leftover PSW data that will conflict
>> with the Format-0 CCW being generated:
>>
>> 0x0: 00080000 80010000
>>         ------ Ccw0.cda
>>                -- Ccw0.chainData
>>                  -- Reserved bits
>>
>> The data address will be overwritten with the correct value (0x0), but
>> the apparent data chain bit will cause subsequent memory to be used as
>> the target of the data store, which may not be where we expect (0x0).
>>
>> Clear out this space when we boot from DASD, so that we know it exists
>> exactly as we expect.
>>
>> Signed-off-by: Eric Farman <farman@linux.ibm.com>
>> Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
>> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> 
> Seems like I should have been more specific with my LGTM:
> Reviewed-by: Janosch Frank <frankja@de.ibm.com>

Thanks, Janosch. I didn't want to put words in your acronym. :)

> 
>> ---
>>   pc-bios/s390-ccw/dasd-ipl.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
>> index 0fc879bb8e..71cbae2f16 100644
>> --- a/pc-bios/s390-ccw/dasd-ipl.c
>> +++ b/pc-bios/s390-ccw/dasd-ipl.c
>> @@ -100,6 +100,9 @@ static void make_readipl(void)
>>   {
>>       Ccw0 *ccwIplRead = (Ccw0 *)0x00;
>>   
>> +    /* Clear out any existing data */
>> +    memset(ccwIplRead, 0, sizeof(Ccw0));
>> +
>>       /* Create Read IPL ccw at address 0 */
>>       ccwIplRead->cmd_code = CCW_CMD_READ_IPL;
>>       ccwIplRead->cda = 0x00; /* Read into address 0x00 in main memory */
>>
>
diff mbox series

Patch

diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
index 0fc879bb8e..71cbae2f16 100644
--- a/pc-bios/s390-ccw/dasd-ipl.c
+++ b/pc-bios/s390-ccw/dasd-ipl.c
@@ -100,6 +100,9 @@  static void make_readipl(void)
 {
     Ccw0 *ccwIplRead = (Ccw0 *)0x00;
 
+    /* Clear out any existing data */
+    memset(ccwIplRead, 0, sizeof(Ccw0));
+
     /* Create Read IPL ccw at address 0 */
     ccwIplRead->cmd_code = CCW_CMD_READ_IPL;
     ccwIplRead->cda = 0x00; /* Read into address 0x00 in main memory */