mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John David Anglin <dave.anglin@bell.net>
To: Charlie Jenkins <charlie@rivosinc.com>,
	Guenter Roeck <linux@roeck-us.net>
Cc: David Laight <David.Laight@aculab.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Helge Deller <deller@gmx.de>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Parisc List <linux-parisc@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests
Date: Thu, 15 Feb 2024 12:13:43 -0500	[thread overview]
Message-ID: <378dba2c-ebc2-404d-a0e8-f507a24ef6d2@bell.net> (raw)
In-Reply-To: <Zc5A+c0gmxtygNIa@ghost>

On 2024-02-15 11:51 a.m., Charlie Jenkins wrote:
> On Thu, Feb 15, 2024 at 08:30:22AM -0800, Guenter Roeck wrote:
>> On 2/15/24 07:36, Charlie Jenkins wrote:
>>> On Thu, Feb 15, 2024 at 12:56:13AM -0800, Guenter Roeck wrote:
>>>> On 2/14/24 19:35, Charlie Jenkins wrote:
>>>>> On Wed, Feb 14, 2024 at 10:00:37PM -0500, John David Anglin wrote:
>>>>>> On 2024-02-14 8:58 p.m., Guenter Roeck wrote:
>>>>>>> Specifically: Yes, the carry/borrow bits should be restored. Question is
>>>>>>> if the Linux kernel's interrupt handler doesn't restore the carry bits
>>>>>>> or if the problem is on the qemu side.
>>>>>> The carry/borrow bits in the PSW should be saved and restored by the save_specials
>>>>>> and rest_specials macros.  They are defined in arch/parisc/include/asm/assembly.h.
>>>>> Why would they be needed to be restored in linux? The manual says "The
>>>>> PSW is set to the contents of the IPSW by the RETURN FROM INTERRUPTION
>>>>> instruction". This means that the PSW must be restored by the hardware.
>>>>>
>>>>> We can see the QEMU implementation in:
>>>>>
>>>>> rfi:
>>>>> https://github.com/qemu/qemu/blob/v8.2.1/target/hppa/sys_helper.c#L93
>>>>>
>>>>> handling interrupt:
>>>>> https://github.com/qemu/qemu/blob/v8.2.1/target/hppa/int_helper.c#L109
>>>>>
>>>>> However the implementation appears to be faulty. During an RFI, the PSW
>>>>> is always set to 0x804000e (regardless of what the PSW was before the
>>>>> interrupt).
>>>>>
>>>> Not sure if I agree. The interrupt handler in Linux is the one which needs to set
>>>> IPSW. Looking into the code, I agree with Dave that the tophys macro seems to
>>>> clobber the carry bits before psw is saved, so they can not really be restored.
>>>> The only issue with that idea is that I can only reproduce the problem with
>>>> an interrupted ldd instruction but not, for example, with ldw. This is why it
>>>> would be really important to have someone with real hardware test this.
>>>>
>>>> Thanks,
>>>> Guenter
>>> Yes, we definitely feedback from somebody with access to hardware, but I
>>> do not understand how "The PSW is set to the contents of the IPSW by the
>>> RETURN FROM INTERRUPTION" could be interpreted as anything except that
>>> the hardware is expected to over-write the contents of the PSW during
>>> the rfi.
>>>
>> Sure, I absolutely agree. But that assumes that IPSW is set correctly
>> in the Linux interrupt handler. We do know that something odd happens
> The manual defines the saving of PSW as the responsibility of the
> hardware as well: "When an interruption occurs, the current value of the
> PSW is saved in the Interruption Processor Status Word (IPSW)". I don't
> think this should be interpreted to mean that a software interrupt
> handler is required to save the IPSW.
The IPSW (cr22) is saved by save_specials to regs->gr[0].  It is modified in various
places when an interruption is handled.  In the case of emulate_ldd, we have

         /* else we handled it, let life go on. */
         regs->gr[0]|=PSW_N;

This is supposed to nullify the faulting ldd.  I've yet to find where the carry bit is getting
set in the PSW.

There is a gap between where the hardware sets IPSW and where it is saved to the stack
in save_specials.  tophys might clobber the IPSW is there is a double fault.  But it seems
more likely that regs->gr[0] is getting clobbered somehow.

Dave
>
> - Charlie
>
>> when an unaligned ldd is encountered. At least for my part I don't know
>> if the problem is in emulate_ldd() in the Linux kernel or in the ldd
>> implementation and trap handling in qemu. I do know (from my logs)
>> that qemu does see the correct PSW/IPSW values, because they do
>> show up correctly in the Linux kernel when running the qemu emulation.
>> Only it somehow gets lost when the Linux interrupt handler returns.
>>
>> Thanks.
>> Guenter
>>


-- 
John David Anglin  dave.anglin@bell.net


  reply	other threads:[~2024-02-15 17:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 21:41 [PATCH v8 0/2] lib: checksum: Fix issues with checksum tests Charlie Jenkins
2024-02-14 21:41 ` [PATCH v8 1/2] lib: checksum: Fix type casting in checksum kunits Charlie Jenkins
2024-02-14 21:41 ` [PATCH v8 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Charlie Jenkins
2024-02-14 23:03   ` Guenter Roeck
2024-02-15  1:30     ` Charlie Jenkins
2024-02-15  1:58       ` Guenter Roeck
2024-02-15  3:00         ` John David Anglin
2024-02-15  3:35           ` Charlie Jenkins
2024-02-15  4:11             ` Charlie Jenkins
2024-02-15  8:56             ` Guenter Roeck
2024-02-15 15:36               ` Charlie Jenkins
2024-02-15 16:30                 ` Guenter Roeck
2024-02-15 16:51                   ` Charlie Jenkins
2024-02-15 17:13                     ` John David Anglin [this message]
2024-02-15 17:29                     ` Guenter Roeck
2024-02-15 15:22           ` Guenter Roeck
2024-02-16  5:54         ` Helge Deller
2024-02-16  5:25           ` Guenter Roeck
2024-02-16  7:31             ` Helge Deller
2024-02-16  6:58               ` Guenter Roeck
2024-02-16  6:09           ` Guenter Roeck
2024-02-16  6:13             ` Charlie Jenkins
2024-02-16 12:05               ` Helge Deller
2024-02-16 18:22           ` John David Anglin
2024-02-15 10:27     ` David Laight
2024-02-15 15:44       ` Guenter Roeck
2024-02-15 16:51         ` John David Anglin
2024-02-15 17:06           ` Guenter Roeck
2024-02-15 17:25             ` John David Anglin
2024-02-15 18:17               ` Guenter Roeck
2024-02-15 18:56                 ` John David Anglin
2024-02-15 21:00                   ` Guenter Roeck
2024-02-15 21:08                     ` John David Anglin
2024-02-15 18:42               ` Guenter Roeck
2024-02-15 19:41                 ` David Laight
2024-02-15 19:42                 ` Charlie Jenkins
2024-02-16  5:00                   ` Guenter Roeck
2024-02-15  1:24   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=378dba2c-ebc2-404d-a0e8-f507a24ef6d2@bell.net \
    --to=dave.anglin@bell.net \
    --cc=David.Laight@aculab.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=charlie@rivosinc.com \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=palmer@dabbelt.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®