[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] xen/ppc: Implement early serial printk on pseries


  • To: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 21 Jun 2023 19:46:08 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SGLkj4TUiEKuMMbJqtiiOqcjFW3vOw5+T+56DZ0G/2U=; b=Vbpf2kkCjGD/hupXlFKbRdlH3ZoigpGvwZamLN1ZjWD3MsNSzx5HRtQLEt9Yrhb/4JaIJ4qSXOwK2M/ejOlaAdkyw6Unrr/5Xpidym46mV28o1J+aNvx99gLpoSPVkdBphjHSMyyl0/6+T+6XBdo6dlzhfZL4yJBzb6HDnTXc3fmfCs+W4lsCDlevP2M1z8VWjUwt0AFj4mEa3fTr+HHARWWgbLh7kBqNeO8Qc8DHgVR0GfatCzPurepvKKP4bkxrCTYhBq5cW/gJokvV1FWfOxL3Bbzoe3ACJTEj3GAabzWtfChR1OZJterBv6GjbOEgXv58YPXItDnLaqnlo+vvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GnNJR5FpLsbNhO0Oj7sbn2e6KG3I39aXR3T6fNjmlFhQUlVaDChVZG0uCu/sM3ItucMlasFSaRffmjk/BGy4+aRRA8hrNTMeBTLe65o1upNfVz58YckR6yR4nxhn1DskCZyeHdtuckl5C5g545J18ksybuWw8xtmrNxmVi71ubJ6+s+lw/aSuZHp/KS2QkqI8j3etoFdBfF/RzU162iQ8omf7hCP7MRW85oKFx71iCJxkiwwqFYXsOd0m90bY3+LDR3eZqFRR/1qvWxqvu27OKSUl6X08Wx4RWrlrxDGc8oqYxwTXgddhy4SsUuNNy5C3KhL6oRIbFzWFWpY9pH1pw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: tpearson@xxxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 21 Jun 2023 18:46:51 +0000
  • Ironport-data: A9a23:sowgbqk411vR+BmK0bwJFL/o5gxPJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xJOUW+Ca/iNZWHweIt+O4m2oxgFu5TdnN4yHQA/qig8ESMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icfHgqH2eIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE0p5KyaVA8w5ARkPqgV5gaGyxH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 dciDCtRSjOdvLzowIP8drVB2soIPPC+aevzulk4pd3YJdAPZMmbBo/suppf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVk1Q3ieC8WDbWUoXiqcF9t0CUv G/ZuU/+BQkXLoe3wjuZ6HO8wOTImEsXXapLTefkrqc23QX7Kmo7LDQJS3K7i6GCrRS5YNAHe w8tpRoBov1nnKCsZpynN/Gim1aftxgVQMZZCOw9wBuE0rbT+QufCWkCQzNbadop8sQxQFQCx lKP2t/kGzFrmLmUUm6GsKeZqyuoPioYJnNEYjULJSMZ+9Tqupo0iDrVR85/F7S4iNL0Hzz92 TGMo241gLB7sCIQ/6Cy/FSCiTTzoJHMF1Yx/l+OBjPj6R5lbom4YYDu8ULc8ftLMIeeSB+Go WQAnM+dqusJCPlhiRCwfQnEJ5nxj97tDdEWqQcH80UJn9h1x0OeQA==
  • Ironport-hdrordr: A9a23:PU8YiKmnCKg9j25HnnpiKPQzSOTpDfJP3DAbv31ZSRFFG/Fw9v rPoB1/73TJYVkqNU3I9errBEDiexLhHOBOjrX5VI3KNDUO01HFEGgN1+Xf/wE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21/06/2023 7:21 pm, Shawn Anastasio wrote:
> On 6/21/23 12:54 PM, Andrew Cooper wrote:
>> On 21/06/2023 5:59 pm, Shawn Anastasio wrote:
>>>  xen/arch/ppc/Kconfig.debug              |   5 +
>>>  xen/arch/ppc/Makefile                   |   3 +
>>>  xen/arch/ppc/boot-of.c                  | 116 +++++++++++++
>>>  xen/arch/ppc/configs/ppc64_defconfig    |   1 +
>>>  xen/arch/ppc/early_printk.c             |  28 +++
>>>  xen/arch/ppc/include/asm/boot.h         |  24 +++
>>>  xen/arch/ppc/include/asm/bug.h          |   6 +
>>>  xen/arch/ppc/include/asm/byteorder.h    |  37 ++++
>>>  xen/arch/ppc/include/asm/cache.h        |   6 +
>>>  xen/arch/ppc/include/asm/early_printk.h |  15 ++
>>>  xen/arch/ppc/include/asm/msr.h          |  67 ++++++++
>>>  xen/arch/ppc/include/asm/processor.h    | 207 ++++++++++++++++++++++
>>>  xen/arch/ppc/include/asm/reg_defs.h     | 218 ++++++++++++++++++++++++
>>>  xen/arch/ppc/include/asm/string.h       |   6 +
>>>  xen/arch/ppc/include/asm/types.h        |  35 ++++
>>>  xen/arch/ppc/ppc64/Makefile             |   1 +
>>>  xen/arch/ppc/ppc64/asm-offsets.c        |  55 ++++++
>>>  xen/arch/ppc/ppc64/head.S               |  48 +++---
>>>  xen/arch/ppc/ppc64/of-call.S            |  85 +++++++++
>>>  xen/arch/ppc/setup.c                    |  31 ++++
>>>  20 files changed, 972 insertions(+), 22 deletions(-)
>>>  create mode 100644 xen/arch/ppc/boot-of.c
>>>  create mode 100644 xen/arch/ppc/early_printk.c
>>>  create mode 100644 xen/arch/ppc/include/asm/boot.h
>>>  create mode 100644 xen/arch/ppc/include/asm/bug.h
>>>  create mode 100644 xen/arch/ppc/include/asm/byteorder.h
>>>  create mode 100644 xen/arch/ppc/include/asm/cache.h
>>>  create mode 100644 xen/arch/ppc/include/asm/early_printk.h
>>>  create mode 100644 xen/arch/ppc/include/asm/msr.h
>>>  create mode 100644 xen/arch/ppc/include/asm/processor.h
>>>  create mode 100644 xen/arch/ppc/include/asm/reg_defs.h
>>>  create mode 100644 xen/arch/ppc/include/asm/string.h
>>>  create mode 100644 xen/arch/ppc/include/asm/types.h
>>>  create mode 100644 xen/arch/ppc/ppc64/of-call.S
>>>  create mode 100644 xen/arch/ppc/setup.c
>> This is a surprising amount of infrastructure.  I'm guessing it's a
>> consequence of needing byteorder ?
> Right, byteorder as well as va_{start,end,arg}. I could try to trim it
> down further.

<xen/stdarg.h> should be entirely standalone.

But in general, it's nice to see if we can reduce the
inter-dependencies, and bringup of a new arch is the only time we get to
see them.

>
>> There's a series still out deleting swathes of junk in byteorder.  I
>> guess I need to kick that thread again, but it mostly boils down to
>> using __builtin_bswap$N() (and on x86, reimplementing them on old enough
>> compilers).  Presumably all versions of GCC (and eventually Clang) we
>> care to support with ppc64 understand this builtin ?
> Yes, those builtins should work just fine on any reasonably recent gcc
> or clang toolchain. What would be the correct approach to integrating
> these into byteorder.h? Would adding some `#define __arch_swab$N
> __builtin_bswap$N` macros be the way to go?

In the short term, that's perhaps best.

https://lore.kernel.org/xen-devel/cover.1653314499.git.lin.liu@xxxxxxxxxx/T/#u
is the full series

>> Similarly, there are some functions which ought to be __init, so it
>> would be good to get them correct from the start.
> Good catch. This actually goes along with your subsequent observation
> about Open Firmware residing in the bottom 4G of memory. See below.
>
>> Maybe as an intermediate step, just get the infinite loop moved from asm
>> up into C?  That gets the stack setup, and various of the asm helpers,
>> without all the rest of the C required to get early_printk() to work.
> Would you like that plus the serial patch in this same series, or would
> you like me to just get the C infinite loop going for this series?

Whatever is easier, although I expect splitting this patch into two will
make things simpler overall.

>> A couple of questions before I dive further in.
>>
>> Given:
>>
>> #define r0  0
>>
>> do the assemblers really not understand register names?  That seems mad.
> Yeah as surprising as it is, ppc64 assemblers don't handle register
> names by default. I think at some point a flag was added to GAS (and
> probably llvm? will have to check) to define them for you, but I'm not
> sure which version introduced the flag.
>
> I'll do some digging and if the flag is available a reasonable versions
> of both toolchains (what exactly would constitute this? Are there
> project-wide expectations of older toolchains working, and if so, how
> old?) then I can get rid of these.

You can pick a minimum version as you see fit, which is basically
anything goes prior to PPC64 being declared supported in Xen.

It needs to end up in the root README (but a patch for that probably
wants to wait until the port is a little more mature), but if I were you
I wouldn't care about supporting anything older than comes in current
distro released this year.

>> Also, given the transformations to call into OpenFirmware, presumably
>> this limits Xen to running below the 4G boundary and on identity mappings?
> Interaction with Open Firmware directly shouldn't be necessary past
> early init, so it shouldn't impose any restrictions on the memory map
> once paging is up and going. It will just require grabbing all of the
> required information from OF (essentially dumping the device tree into a
> local copy) before making the switch.
>
> I'll also mark the relevant functions as __init.

Ah, in which case there's something magic in the build system which is
(AFAIU) unique to Xen.

obj-y += foo.init.o

for a foo.o which are expected to contain no runtime code at all.  This
trick also manages to string literals into .init.rodata, rather than
living in the general mergable string section.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.