]> xenbits.xensource.com Git - xen.git/log
xen.git
2 years agox86/MSI: use standard C types in structures/unions
Jan Beulich [Tue, 21 Feb 2023 14:08:38 +0000 (15:08 +0100)]
x86/MSI: use standard C types in structures/unions

Consolidate this to use exclusively standard types, and change
indentation style to Xen's there at the same time (the file already had
a mix of styles).

While there
- switch boolean fields to use bool,
- drop the notion of big-endian bitfields being a thing on x86,
- drop the names for reserved fields,
- adjust the comment on "dest32".

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/ucode/AMD: apply the patch early on every logical thread
Sergey Dyasli [Tue, 21 Feb 2023 14:08:05 +0000 (15:08 +0100)]
x86/ucode/AMD: apply the patch early on every logical thread

The original issue has been reported on AMD Bulldozer-based CPUs where
ucode loading loses the LWP feature bit in order to gain the IBPB bit.
LWP disabling is per-SMT/CMT core modification and needs to happen on
each sibling thread despite the shared microcode engine. Otherwise,
logical CPUs will end up with different cpuid capabilities.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216211
Guests running under Xen happen to be not affected because of levelling
logic for the feature masking/override MSRs which causes the LWP bit to
fall out and hides the issue. The latest recommendation from AMD, after
discussing this bug, is to load ucode on every logical CPU.

In Linux kernel this issue has been addressed by e7ad18d1169c
("x86/microcode/AMD: Apply the patch early on every logical thread").
Follow the same approach in Xen.

Introduce SAME_UCODE match result and use it for early AMD ucode
loading. Take this opportunity and move opt_ucode_allow_same out of
compare_revisions() to the relevant callers and also modify the warning
message based on it. Intel's side of things is modified for consistency
but provides no functional change.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agox86: use standard C types in struct cpuinfo_x86
Jan Beulich [Tue, 21 Feb 2023 14:06:55 +0000 (15:06 +0100)]
x86: use standard C types in struct cpuinfo_x86

Consolidate this to use exclusively standard types, and change oprofile
code (apparently trying to mirror those types) at the same time. Where
sensible actually drop local variables.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/svm: cleanup svm.c
Xenia Ragiadakou [Fri, 17 Feb 2023 18:48:11 +0000 (20:48 +0200)]
x86/svm: cleanup svm.c

Do not include the headers:
  xen/irq.h
  asm/hvm/svm/intr.h
  asm/io.h
  asm/mem_sharing.h
  asm/regs.h
because none of the declarations and macro definitions in them is used.
Sort the rest of the headers alphabetically.

Remove the forward declaration of svm_function_table and place start_svm()
after the svm_function_table's definition.

Replace double new lines with one.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agodocs/process: branching-checklist: Add a list of accounts at the beginning
Julien Grall [Sun, 19 Feb 2023 18:43:16 +0000 (18:43 +0000)]
docs/process: branching-checklist: Add a list of accounts at the beginning

The checklist requires to have access to several accounts on both
xenbits and osstest. List those accounts at the beginning of the file
so it is easier to check if one has the permissions before starting
the branching process.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
----
    Changes in v2:
        - Add Henry's reviewed-by

2 years agodocs/proces: branching-checklist: Update the section "add to patchbot"
Julien Grall [Sun, 19 Feb 2023 18:43:15 +0000 (18:43 +0000)]
docs/proces: branching-checklist: Update the section "add to patchbot"

Make clear the patchbot is accessible from the user "xen" on xenbits.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
----
    Changes in v2:
        - Add Henry's reviewed-by
        - Add George's acked-by

2 years agodocs/process: branching-checklist: Remove section about the cambridge colo
Julien Grall [Sun, 19 Feb 2023 18:43:14 +0000 (18:43 +0000)]
docs/process: branching-checklist: Remove section about the cambridge colo

The cambridge colo was internal to Citrix (now Cloud) and hasn't been used
by the community for a while.

So remove the section.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
----
    Changes in v2:
        - Add George's acked-by
        - Add Henry's reviewed-by

2 years agodocs/process: branching-checklist: Reword the section about Config.mk
Julien Grall [Sun, 19 Feb 2023 18:42:42 +0000 (18:42 +0000)]
docs/process: branching-checklist: Reword the section about Config.mk

Since at least Xen 4.12, the revision for external trees don't contain
the word "unstable". So explicitly list the *_REVISION variables that
need to be updated as part of the branching process.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
----
    Changes in v2:
        * Explain what should be the tag format for each variables

2 years agotools: Remove the use of K&R functions
Andrew Cooper [Thu, 16 Feb 2023 22:47:50 +0000 (22:47 +0000)]
tools: Remove the use of K&R functions

Clang-15 (as seen in the FreeBSD 14 tests) complains:

  xg_main.c:1248 error: a function declaration without a
  prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
  xg_init()
         ^
          void

The error message is a bit confusing but appears to new as part of
-Wdeprecated-non-prototype which is part of supporting C2x which formally
removes K&R syntax.

Either way, fix the identified function.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
2 years agoxen/x86: Remove the use of K&R functions
Andrew Cooper [Thu, 16 Feb 2023 22:14:12 +0000 (22:14 +0000)]
xen/x86: Remove the use of K&R functions

Clang-15 (as seen in the FreeBSD 14 tests) complains:

  arch/x86/time.c:1364:20: error: a function declaration without a
  prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
  s_time_t get_s_time()
                     ^
                      void

The error message is a bit confusing but appears to new as part of
-Wdeprecated-non-prototype which is part of supporting C2x which formally
removes K&R syntax.

Either way, fix the identified functions.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agolibs: Fix unstable libs build with LLVM, auto-generate version-script
Anthony PERARD [Thu, 16 Feb 2023 14:10:07 +0000 (14:10 +0000)]
libs: Fix unstable libs build with LLVM, auto-generate version-script

Unfortunatly, --default-symver doesn't work with LLVM's LD, LLD.
Instead, we will generate a temporary version-script.

In order to allow regenerating the script, we'll have a different
filename. In order to check if the content is up-to-date, we'll always
generated it and compare.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Fixes: 98d95437edb6 ("libs: Fix auto-generation of version-script for unstable libs")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoxen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
Julien Grall [Mon, 30 Jan 2023 18:28:58 +0000 (18:28 +0000)]
xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()

The lock is not meant to be modified by _rw_is{,_write}_locked(). So
constify it.

This is helpful to be able to assert if the lock is taken when the
underlying structure is const.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agoxen/common: Constify the parameter of _spin_is_locked()
Julien Grall [Fri, 27 Jan 2023 19:05:16 +0000 (19:05 +0000)]
xen/common: Constify the parameter of _spin_is_locked()

The lock is not meant to be modified by _spin_is_locked(). So constify
it.

This is helpful to be able to assert the locked is taken when the
underlying structure is const.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Tested-by: Henry Wang <Henry.Wang@arm.com> #Arm
2 years agox86/vlapic: call vmx_vlapic_msr_changed through an hvm_function callback
Xenia Ragiadakou [Thu, 16 Feb 2023 09:15:35 +0000 (10:15 +0100)]
x86/vlapic: call vmx_vlapic_msr_changed through an hvm_function callback

APIC virtualization support is currently implemented only for Intel VT-x.
To aid future work on separating AMD-V from Intel VT-x code, instead of
calling directly vmx_vlapic_msr_changed() from common hvm code, add a stub
to the hvm_function_table, named update_vlapic_mode, and create a wrapper
function, called hvm_vlapic_mode(), to be used by common hvm code.

After the change above, do not include header asm/hvm/vmx/vmx.h as it is
not required anymore and resolve subsequent build errors for implicit
declaration of functions ‘TRACE_2_LONG_3D’ and ‘TRC_PAR_LONG’ by including
missing asm/hvm/trace.h header.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2 years agoACPI/CPER: use standard C types
Jan Beulich [Thu, 16 Feb 2023 09:14:49 +0000 (10:14 +0100)]
ACPI/CPER: use standard C types

Consolidate cper.h to use exclusively standard types.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoxen/arm: Print return code from domain_create and construct_dom{0,U} on panic
Michal Orzel [Mon, 6 Feb 2023 13:05:28 +0000 (14:05 +0100)]
xen/arm: Print return code from domain_create and construct_dom{0,U} on panic

This might be helpful in providing additional debugging information (in
most cases, at least to distinguish -EINVAL from -ENOMEM), so modify the
code to include printing return code in panic message. In create_dom0,
move the call to alloc_dom0_vcpu0() to a separate condition and call a
meaningful panic message.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoautomation: Add a true dom0less test on arm32
Michal Orzel [Tue, 14 Feb 2023 15:38:42 +0000 (16:38 +0100)]
automation: Add a true dom0less test on arm32

Add a new test job qemu-smoke-dom0less-arm32-gcc-without-dom0 in debug
and non-debug variant that will execute qemu-smoke-dom0less-arm32.sh
script to test dom0less domU boot without dom0 (i.e. true dom0less
configuration).

By passing "without-dom0" as a test variant, the test will clear the
dom0 prompt that we grep for as a last step and remove all the DOM0
related options in ImageBuilder configuration.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoautomation: Add a gzip compressed kernel image test on arm32
Michal Orzel [Tue, 14 Feb 2023 15:38:41 +0000 (16:38 +0100)]
automation: Add a gzip compressed kernel image test on arm32

Xen supports booting gzip compressed kernels, therefore add a new test
job qemu-smoke-dom0less-arm32-gcc-gzip in debug and non-debug variant
that will execute qemu-smoke-dom0less-arm32.sh script to test booting
a domU with a gzip compressed kernel image (in our case zImage).

By passing "gzip" as a test variant, the test will call gzip command
to compress kernel image and use it in ImageBuilder configuration for
domU1. No need for a specific check to be executed from domU. Being able
to see a test message from a boot log is sufficient to mark a test as
passed.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoautomation: Add a static memory allocation test on arm32
Michal Orzel [Tue, 14 Feb 2023 15:38:40 +0000 (16:38 +0100)]
automation: Add a static memory allocation test on arm32

Add a new test job qemu-smoke-dom0less-arm32-gcc-staticmem in debug
and non-debug variant that will execute qemu-smoke-dom0less-arm32.sh
script to test static memory allocation feature. The test case itself
is directly taken from dom0less arm64 testing.

Populate build jobs to compile Xen with config options necessary to
enable static memory feature. Populate test jobs passing "static-mem"
as a test variant. The test configures domU with a static memory region
(direct-mapped) and adds a check using /proc/iomem to determine the
memory region marked as "System RAM".

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoautomation: Add arm32 dom0less testing
Michal Orzel [Tue, 14 Feb 2023 15:38:39 +0000 (16:38 +0100)]
automation: Add arm32 dom0less testing

At the moment, we only perform a single arm32 test in our CI, checking
whether dom0 boots successfully or not. This is mostly because we do not
have any arm32 runners and we only execute a hypervisor only build.

In order not to leave the arm32 testing in such a poor state, add a
script qemu-smoke-dom0less-arm32.sh to start testing dom0less
configuration, while keeping dom0 to make the test more interesting.

The script is mostly based on the one used for dom0 arm32 testing as well
as the one used for dom0less arm64 testing. We obtain Debian Bullseye
kernel and Alpine Linux busybox-based rootfs. Depending on the test
variant, we prepare a test case contained within domU_check variable,
that will be executed as part of /init script from domU rootfs.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoautomation: Switch arm32 cross builds to run on arm64
Michal Orzel [Tue, 14 Feb 2023 15:38:38 +0000 (16:38 +0100)]
automation: Switch arm32 cross builds to run on arm64

Due to the limited x86 CI resources slowing down the whole pipeline,
switch the arm32 cross builds to be executed on arm64 which is much more
capable. For that, rename the existing debian container dockerfile
from unstable-arm32-gcc to unstable-arm64v8-arm32-gcc and use
arm64v8/debian:unstable as an image. Note, that we cannot use the same
container name as we have to keep the backwards compatibility.
Take the opportunity to remove extra empty line at the end of a file.

Modify the tag of .arm32-cross-build-tmpl to arm64 and update the build
jobs accordingly.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agobuild: make FILE symbol paths consistent
Ross Lagerwall [Wed, 15 Feb 2023 15:13:49 +0000 (16:13 +0100)]
build: make FILE symbol paths consistent

The FILE symbols in out-of-tree builds may be either a relative path to
the object dir or an absolute path depending on how the build is
invoked. Fix the paths for C files so that they are consistent with
in-tree builds - the path is relative to the "xen" directory (e.g.
common/irq.c).

This fixes livepatch builds when the original Xen build was out-of-tree
since livepatch-build always does in-tree builds. Note that this doesn't
fix the behaviour for Clang < 6 which always embeds full paths.

Fixes: 7115fa562fe7 ("build: adding out-of-tree support to the xen build")
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agocredit2: respect credit2_runqueue=all when arranging runqueues
Marek Marczykowski-Górecki [Wed, 15 Feb 2023 15:12:42 +0000 (16:12 +0100)]
credit2: respect credit2_runqueue=all when arranging runqueues

Documentation for credit2_runqueue=all says it should create one queue
for all pCPUs on the host. But since introduction
sched_credit2_max_cpus_runqueue, it actually created separate runqueue
per socket, even if the CPUs count is below
sched_credit2_max_cpus_runqueue.

Adjust the condition to skip syblink check in case of
credit2_runqueue=all.

Fixes: 8e2aa76dc167 ("xen: credit2: limit the max number of CPUs in a runqueue")
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
2 years agox86/spec-ctrl: Mitigate Cross-Thread Return Address Predictions
Andrew Cooper [Thu, 8 Sep 2022 20:27:58 +0000 (21:27 +0100)]
x86/spec-ctrl: Mitigate Cross-Thread Return Address Predictions

This is XSA-426 / CVE-2022-27672

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agox86/iommu: make AMD-Vi and Intel VT-d support configurable
Xenia Ragiadakou [Mon, 13 Feb 2023 15:30:06 +0000 (16:30 +0100)]
x86/iommu: make AMD-Vi and Intel VT-d support configurable

Provide the user with configuration control over the IOMMU support by making
AMD_IOMMU and INTEL_IOMMU options user selectable and able to be turned off.

However, there are cases where the IOMMU support is required, for instance for
a system with more than 254 CPUs. In order to prevent users from unknowingly
disabling it and ending up with a broken hypervisor, make the support user
selectable only if EXPERT is enabled.

To preserve the current default configuration of an x86 system, both options
depend on X86 and default to Y.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 years agox86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code
Xenia Ragiadakou [Mon, 13 Feb 2023 15:29:20 +0000 (16:29 +0100)]
x86/dpci: move hvm_dpci_isairq_eoi() to generic HVM code

The function hvm_dpci_isairq_eoi() has no dependencies on VT-d driver code
and can be moved from xen/drivers/passthrough/vtd/x86/hvm.c to
xen/drivers/passthrough/x86/hvm.c, along with the corresponding copyrights.

Remove the now empty xen/drivers/passthrough/vtd/x86/hvm.c.

Since the function is used only in this file, declare it static.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2 years agox86/iommu: call pi_update_irte through an hvm_function callback
Xenia Ragiadakou [Mon, 13 Feb 2023 15:28:32 +0000 (16:28 +0100)]
x86/iommu: call pi_update_irte through an hvm_function callback

Posted interrupt support in Xen is currently implemented only for the
Intel platforms. Instead of calling directly pi_update_irte() from the
common hvm code, add a pi_update_irte callback to the hvm_function_table.
Then, create a wrapper function hvm_pi_update_irte() to be used by the
common hvm code.

In the pi_update_irte callback prototype, pass the vcpu as first parameter
instead of the posted-interrupt descriptor that is platform specific, and
remove the const qualifier from the parameter gvec since it is not needed
and because it does not compile with the alternative code patching in use.

Since the posted interrupt descriptor is Intel VT-x specific while
msi_msg_write_remap_rte is iommu specific, open code pi_update_irte() inside
vmx_pi_update_irte() but replace msi_msg_write_remap_rte() with generic
iommu_update_ire_from_msi(). That way vmx_pi_update_irte() is not bound to
Intel VT-d anymore.

Remove the now unused pi_update_irte() implementation.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2 years agox86/iommu: make code addressing CVE-2011-1898 no VT-d specific
Xenia Ragiadakou [Mon, 13 Feb 2023 15:27:39 +0000 (16:27 +0100)]
x86/iommu: make code addressing CVE-2011-1898 no VT-d specific

The variable untrusted_msi indicates whether the system is vulnerable to
CVE-2011-1898 due to the absence of interrupt remapping support.
Although AMD iommus with interrupt remapping disabled are also affected,
this case is not handled yet. Given that the issue is not VT-d specific,
and to accommodate future use of the flag for covering also the AMD iommu
case, move the definition of the flag out of the VT-d specific code to the
common x86 iommu code.

Also, since the current implementation assumes that only PV guests are prone
to this attack, take the opportunity to define untrusted_msi only when PV is
enabled.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2 years agox86/iommu: snoop control is allowed only by Intel VT-d
Xenia Ragiadakou [Mon, 13 Feb 2023 15:26:43 +0000 (16:26 +0100)]
x86/iommu: snoop control is allowed only by Intel VT-d

The AMD-Vi driver forces coherent accesses by hardwiring the FC bit to 1.
Therefore, given that iommu_snoop is used only when the iommu is enabled,
when Xen is configured with only the AMD iommu enabled, iommu_snoop can be
reduced to a #define to true.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agox86/shadow: make iommu_snoop usage consistent with HAP's
Jan Beulich [Mon, 13 Feb 2023 15:26:03 +0000 (16:26 +0100)]
x86/shadow: make iommu_snoop usage consistent with HAP's

First of all the variable is meaningful only when an IOMMU is in use for
a guest. Qualify the check accordingly, like done elsewhere. Furthermore
the controlling command line option is supposed to take effect on VT-d
only. Since command line parsing happens before we know whether we're
going to use VT-d, force the variable back to set when instead running
with AMD IOMMU(s).

Since it may end up misleading, also remove the clearing of the flag in
iommu_setup() and vtd_setup()'s error path. The variable simply is
meaningless with IOMMU(s) disabled, so there's no point touching it
there.

Finally also correct a relevant nearby comment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2 years agobuild: move double-$ into as-option-add
Jan Beulich [Mon, 13 Feb 2023 09:13:47 +0000 (10:13 +0100)]
build: move double-$ into as-option-add

It's imo helping readability as well as uses a little if properly
arranging for sufficiently late macro expansion is part of the macro
itself, rather than all (applicable) instances of its users.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
2 years agoxen/public: fix 9pfs documentation of connection sequence
Juergen Gross [Mon, 13 Feb 2023 09:10:24 +0000 (10:10 +0100)]
xen/public: fix 9pfs documentation of connection sequence

The documented connection sequence in xen/include/public/io/9pfs.h has
a bug: the frontend needs to wait for the backend to have published its
features before being able to allocate its rings and event-channels.

While correcting that, make it clear that there might be multiple
rings and event-channels by adding "(s)".

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoxen/public: fix 9pfs Xenstore entry documentation
Juergen Gross [Mon, 13 Feb 2023 09:10:06 +0000 (10:10 +0100)]
xen/public: fix 9pfs Xenstore entry documentation

In xen/include/public/io/9pfs.h the documentation regarding the
Xenstore entries isn't reflecting reality: the "tag" Xenstore entry
is on the frontend side, not on the backend one.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agox86/shadow: re-work 4-level SHADOW_FOREACH_L2E()
Jan Beulich [Mon, 13 Feb 2023 09:09:15 +0000 (10:09 +0100)]
x86/shadow: re-work 4-level SHADOW_FOREACH_L2E()

First of all move the almost loop-invariant condition out of the loop;
transform it into an altered loop boundary, noting that the updating of
_gl2p is relevant only at one use site, and then also only inside the
_code blob it provides. Then drop the shadow_mode_external() part of the
condition as being redundant with the is_pv_32bit_domain() check.
Further, since the new local variable wants to be "unsigned int",
convert the loop induction variable accordingly. Finally also adjust
formatting as most code needs touching anyway.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/shadow: rename hash_domain_foreach()
Jan Beulich [Mon, 13 Feb 2023 09:08:44 +0000 (10:08 +0100)]
x86/shadow: rename hash_domain_foreach()

The "domain" in there has become meaningless; drop it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/shadow: drop hash_vcpu_foreach()
Jan Beulich [Mon, 13 Feb 2023 09:08:07 +0000 (10:08 +0100)]
x86/shadow: drop hash_vcpu_foreach()

The domain based variant is easily usable by shadow_audit_tables(); all
that's needed is conversion of the callback functions.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/shadow: replace sh_reset_l3_up_pointers()
Jan Beulich [Mon, 13 Feb 2023 09:07:03 +0000 (10:07 +0100)]
x86/shadow: replace sh_reset_l3_up_pointers()

Rather than doing a separate hash walk (and then even using the vCPU
variant, which is to go away), do the up-pointer-clearing right in
sh_unpin(), as an alternative to the (now further limited) enlisting on
a "free floating" list fragment. This utilizes the fact that such list
fragments are traversed only for multi-page shadows (in shadow_free()
and sh_next_page()). Furthermore sh_terminate_list() is a safe guard
only anyway, which isn't in use in the common case (it actually does
something only for BIGMEM configurations).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoxen/riscv: mask all interrupts
Oleksii Kurochko [Mon, 13 Feb 2023 09:05:39 +0000 (10:05 +0100)]
xen/riscv: mask all interrupts

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: introduce exception handlers implementation
Oleksii Kurochko [Mon, 13 Feb 2023 09:04:48 +0000 (10:04 +0100)]
xen/riscv: introduce exception handlers implementation

The patch introduces an implementation of basic exception handlers:
- to save/restore context
- to handle an exception itself. The handler calls wait_for_interrupt
  now, nothing more.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoriscv: add temporary riscv64_defconfig alias
Jan Beulich [Thu, 9 Feb 2023 09:52:39 +0000 (10:52 +0100)]
riscv: add temporary riscv64_defconfig alias

This is to allow building of Xen without going through a separate
tiny64_defconfig build step, just like is possible for all other
architectures. Eventually the symlink will want replacing by,
presumably, an empty file just like other arches have.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
2 years agox86/shskt: Disable CET-SS on parts susceptible to fractured updates
Andrew Cooper [Fri, 28 Oct 2022 10:40:00 +0000 (11:40 +0100)]
x86/shskt: Disable CET-SS on parts susceptible to fractured updates

Refer to Intel SDM Rev 70 (Dec 2022), Vol3 17.2.3 "Supervisor Shadow Stack
Token".

Architecturally, an event delivery which starts in CPL<3 and switches shadow
stack will first validate the Supervisor Shadow Stack Token (setting the busy
bit), then pushes CS/LIP/SSP.  One example of this is an NMI interrupting Xen.

Some CPUs suffer from an issue called fracturing, whereby a fault/vmexit/etc
between setting the busy bit and completing the event injection renders the
action non-restartable, because when it comes time to restart, the busy bit is
found to be already set.

This is far more easily encountered under virt, yet it is not the fault of the
hypervisor, nor the fault of the guest kernel.  The fault lies somewhere
between the architectural specification, and the uarch behaviour.

Intel have allocated CPUID.7[1].ecx[18] CET_SSS to enumerate that supervisor
shadow stacks are safe to use.  Because of how Xen lays out its shadow stacks,
fracturing is not expected to be a problem on native.

Detect this case on boot and default to not using shstk if virtualised.
Specifying `cet=shstk` on the command line will override this heuristic and
enable shadow stacks irrespective.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agox86/cpuid: Infrastructure for leaves 7:1{ecx,edx}
Andrew Cooper [Fri, 28 Oct 2022 10:40:00 +0000 (11:40 +0100)]
x86/cpuid: Infrastructure for leaves 7:1{ecx,edx}

We don't actually need ecx yet, but adding it in now will reduce the amount to
which leaf 7 is out of order in a featureset.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agodocs: clarify xenstore permission documentation
Juergen Gross [Thu, 9 Feb 2023 14:41:48 +0000 (15:41 +0100)]
docs: clarify xenstore permission documentation

In docs/misc/xenstore.txt the description of the Xenstore node access
permissions is missing one important aspect, which can be found only
in the code or in the wiki [1]:

The first permission entry is defining the owner of the node via the
domid, and the access rights for all domains NOT having a dedicated
permission entry.

Make that aspect clear in the official documentation.

[1]: https://wiki.xenproject.org/wiki/XenBus#Permissions

Reported-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
2 years agoSUPPORT.md: update version to 4.18-unstable
Juergen Gross [Thu, 9 Feb 2023 14:23:57 +0000 (15:23 +0100)]
SUPPORT.md: update version to 4.18-unstable

The current version is no longer 4.17-rc. Update it to "4.18-unstable".

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agotools/ocaml: Drop libxl and xentoollog bindings
Andrew Cooper [Thu, 9 Feb 2023 15:25:10 +0000 (15:25 +0000)]
tools/ocaml: Drop libxl and xentoollog bindings

There are significant issues with these bindings (they segfault for starters)
and their companion half in Xapi was deleted in 2018

  https://github.com/xapi-project/xen-api/commit/203292ebe0c487d7ae4adb961a6d080f4fbe933d

owing to there having been no development of these bindings since 2014.

In the unlikely event that we'd want to reinstate them, they'd need reworking
basically from scratch anyway.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agolibs/util: Fix parallel build between flex/bison and CC rules
Anthony PERARD [Thu, 9 Feb 2023 16:14:48 +0000 (16:14 +0000)]
libs/util: Fix parallel build between flex/bison and CC rules

flex/bison generate two targets, and when those targets are
prerequisite of other rules they are considered independently by make.

We can have a situation where the .c file is out-of-date but not the
.h, git checkout for example. In this case, if a rule only have the .h
file as prerequiste, make will procced and start to build the object.
In parallel, another target can have the .c file as prerequisite and
make will find out it need re-generating and do so, changing the .h at
the same time. This parallel task breaks the first one.

To avoid this scenario, we put both the header and the source as
prerequisite for all object even if they only need the header.

Reported-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agolibs/util: Remove unused headers in libxlu_pci.c
Anthony PERARD [Thu, 9 Feb 2023 12:11:40 +0000 (12:11 +0000)]
libs/util: Remove unused headers in libxlu_pci.c

libxlu_pci.c doesn't use any "xlu__cfg*()" functions and doesn't use
any of the disk parsing functions "xlu__disk*()", so all those headers
can be removed.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agotools/xenstored: hashtable: Constify the parameters of hashfn/eqfn
Julien Grall [Fri, 27 Jan 2023 18:55:46 +0000 (18:55 +0000)]
tools/xenstored: hashtable: Constify the parameters of hashfn/eqfn

The parameters of hashfn/eqfn should never be modified. So constify
them and propagate the const to the users.

Take the opportunity to solve some coding style issues around the
code modified.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
Tested-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
2 years agodocs/process: branching-checklist: Clarify steps to add the branch in osstest
Julien Grall [Thu, 9 Feb 2023 17:07:28 +0000 (17:07 +0000)]
docs/process: branching-checklist: Clarify steps to add the branch in osstest

The steps to add the new branch in osstest doesn't mention the change
should be committed.

Update the steps to clarify that. Take the opportunity to switch to
use $v instead hardcoded version.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
2 years agodocs/process: branching-checklist: Remove reference to root
Julien Grall [Thu, 9 Feb 2023 17:07:13 +0000 (17:07 +0000)]
docs/process: branching-checklist: Remove reference to root

The steps to generate the documentation for the new branch requires
to ssh as root and then su to run with the user xendocs.

The release technician may not (and should not) have access to root.
So update the step to directly ssh as xendocs.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
2 years agodocs/process: branching-checklist: Remove reference to qemu-ijw.git
Julien Grall [Thu, 9 Feb 2023 17:04:41 +0000 (17:04 +0000)]
docs/process: branching-checklist: Remove reference to qemu-ijw.git

Per [1], qemu-iwj.git was a clone of QEMU traditional on Ian's computer
for tagging QEMU trad.

The next section will provide tag for the official tree. So remove
the section about qemu-ijw.git.

[1] 25482.10006.140155.984629@chiark.greenend.org.uk

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
2 years agodocs/process: branching-checklist: Use consistent indentation
Julien Grall [Thu, 9 Feb 2023 17:04:30 +0000 (17:04 +0000)]
docs/process: branching-checklist: Use consistent indentation

At the moment, branch-checklist.txt is using a mix of soft and hard
tab. They are both meant to be represented using 8 characters.

In Xen we tend to use 4-space softtab represented with 4 characters. So
to avoid  having to use a different editor configuration, switch all
the indentation to 4-space softtab.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
Reviewed-by: Henry Wang <Henry.Wang@arm.com>
2 years agox86/paging: return -EINVAL for paging domctls for dying domains
Roger Pau Monné [Tue, 8 Nov 2022 11:38:50 +0000 (12:38 +0100)]
x86/paging: return -EINVAL for paging domctls for dying domains

The current logic returns 0 and leaves the domctl parameter uninitialized for
any parameter fetching operations (like the GET_ALLOCATION operation), which
is not helpful from a toolstack point of view, because there's no indication
that the data hasn't been fetched.

For at least the Ocaml stubs, this ends up passing back stack rubble as if it
were a correct result.

Inform the caller properly that it hasn't got any data.

Reported-by: Edwin Török <edvin.torok@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agotools/helpers: don't log errors when trying to load PVH xenstore-stubdom
Juergen Gross [Fri, 27 Jan 2023 16:17:39 +0000 (17:17 +0100)]
tools/helpers: don't log errors when trying to load PVH xenstore-stubdom

When loading a Xenstore stubdom the loader doesn't know whether the
lo be loaded kernel is a PVH or a PV one. So it tries to load it as
a PVH one first, and if this fails it is loading it as a PV kernel.

This results in errors being logged in case the stubdom is a PV kernel.

Suppress those errors by setting the minimum logging level to
"critical" while trying to load the kernel as PVH.

In case PVH mode and PV mode loading fails, retry PVH mode loading
without changing the log level in order to get the error messages
logged.

Fixes: f89955449c5a ("tools/init-xenstore-domain: support xenstore pvh stubdom")
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agons16550: remove unneeded truncation check in the DT init code
Ayan Kumar Halder [Thu, 9 Feb 2023 10:15:50 +0000 (11:15 +0100)]
ns16550: remove unneeded truncation check in the DT init code

In an earlier commit (7c1de0038895), "ns16550.io_size" was u32 and
"io_size" was u64. Thus, the ASSERT() was needed to check if the values
are the same.
However, in a later commit (c9f8e0aee507), "ns16550.io_size" was changed
to u64. Thus, the ASSERT() became redundant.

So, now as "io_size" and "uart->io_size" are both u64, there will be no
truncation. Thus, one can remove the ASSERT() and extra assignment.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agoxen/riscv: introduce exception context
Oleksii Kurochko [Thu, 9 Feb 2023 10:15:18 +0000 (11:15 +0100)]
xen/riscv: introduce exception context

The patch introduces a set of registers which should be saved to and
restored from a stack after an exception occurs and a set of defines
which will be used during exception context saving/restoring.

Originally <asm/processor.h> header was introduced in the patch series
from Bobby so partially it was
re-used and the following changes were done:
  - Move all RISCV_CPU_USER_REGS_* to asm/asm-offsets.c
  - Remove RISCV_CPU_USER_REGS_OFFSET & RISCV_CPU_USER_REGS_SIZE as
    there is no sense in them after RISCV_CPU_USER_REGS_* were moved to
    asm/asm-offsets.c
  - Remove RISCV_PCPUINFO_* as they aren't needed for current status of
    the RISC-V port
  - register_t renamed to unsigned long
  - rename wait_for_interrupt to wfi

Signed-off-by: Bobby Eshleman <bobby.eshleman@gmail.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: add <asm/csr.h> header
Oleksii Kurochko [Thu, 9 Feb 2023 10:15:08 +0000 (11:15 +0100)]
xen/riscv: add <asm/csr.h> header

The following changes were made in comparison with <asm/csr.h> from
Linux:
  * remove all defines as they are defined in riscv_encoding.h
  * leave only csr_* macros

Origin: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ d2d11f342b17
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: add <asm/asm.h> header
Oleksii Kurochko [Thu, 9 Feb 2023 10:14:53 +0000 (11:14 +0100)]
xen/riscv: add <asm/asm.h> header

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoautomation: add RISC-V smoke test
Oleksii Kurochko [Thu, 9 Feb 2023 10:14:40 +0000 (11:14 +0100)]
automation: add RISC-V smoke test

Add check if there is a message 'Hello from C env' presents
in log file to be sure that stack is set and C part of early printk
is working.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: introduce early_printk basic stuff
Oleksii Kurochko [Thu, 9 Feb 2023 10:13:50 +0000 (11:13 +0100)]
xen/riscv: introduce early_printk basic stuff

Because printk() relies on a serial driver (like the ns16550 driver)
and drivers require working virtual memory (ioremap()) there is not
print functionality early in Xen boot.

The patch introduces the basic stuff of early_printk functionality
which will be enough to print 'hello from C environment".

Originally early_printk.{c,h} was introduced by Bobby Eshleman
(https://github.com/glg-rv/xen/commit/a3c9916bbdff7ad6030055bbee7e53d1aab71384)
but some functionality was changed:
early_printk() function was changed in comparison with the original as
common isn't being built now so there is no vscnprintf.

This commit adds early printk implementation built on the putc SBI call.

As sbi_console_putchar() is already being planned for deprecation
it is used temporarily now and will be removed or reworked after
real uart will be ready.

Signed-off-by: Bobby Eshleman <bobby.eshleman@gmail.com>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Bobby Eshleman <bobby.eshleman@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/arm: Add support for booting gzip compressed uImages
Michal Orzel [Thu, 2 Feb 2023 08:49:05 +0000 (09:49 +0100)]
xen/arm: Add support for booting gzip compressed uImages

At the moment, Xen does not support booting gzip compressed uImages.
This is because we are trying to decompress the kernel before probing
the u-boot header. This leads to a failure as the header always appears
at the top of the image (and therefore obscuring the gzip header).

Move the call to kernel_uimage_probe before kernel_decompress and make
the function self-containing by taking the following actions:
 - take a pointer to struct bootmodule as a parameter,
 - check the comp field of a u-boot header to determine compression type,
 - in case of compressed image, call kernel_decompress passing uImage
   header size as an offset to gzip header,
 - set up zimage.{kernel_addr,len} accordingly,
 - return -ENOENT in case of a u-boot header not found to distinguish it
   amongst other return values and make it the only case for falling
   through to try to probe other image types.

Modify kernel_decompress to take an additional parameter being an offset
to a gzip header from start address. This is needed so that a function
can first operate on a region containing actually compressed kernel (in case
of compressed uImage, size of u-boot header is an offset to a gzip header)
and then at the end pass the entire region (as it was before taking an offset
into account) to fw_unreserved_regions for freeing.

This approach avoids splitting the uImage probing into 2 stages (executed
before and after decompression) which otherwise would be necessary to
properly parse header, update boot module start and size before
decompression and update zimage.{kernel_addr,len} afterwards.

Remove the limitation from the booting.txt documentation.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewwed-by: Julien Grall <jgrall@amazon.com>
2 years agoxen/arm: Move kernel_uimage_probe definition after kernel_decompress
Michal Orzel [Thu, 2 Feb 2023 08:49:04 +0000 (09:49 +0100)]
xen/arm: Move kernel_uimage_probe definition after kernel_decompress

In a follow-up patch, we will be calling kernel_decompress function from
within kernel_uimage_probe to support booting compressed images with
u-boot header. Therefore, move the kernel_uimage_probe definition after
kernel_decompress so that the latter is visible to the former.

No functional change intended.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
2 years agoxen/device_tree: remove incorrect and unused dt_irq() and dt_irq_flags() macros
Xenia Ragiadakou [Fri, 3 Feb 2023 19:09:08 +0000 (21:09 +0200)]
xen/device_tree: remove incorrect and unused dt_irq() and dt_irq_flags() macros

Macro dt_irq() is broken because the macro parameter has the same name with
the struct dt_irq member "irq".
Macro dt_irq_flags() is broken as well because struct dt_irq has no member
named "flags".

Since no one seems to have ever tried to use them and eventually stumble upon
the issues above, remove them instead of fixing them.

Fixes: 886f34045bf0 ("xen/arm: Add helpers to retrieve an interrupt description from the device tree")
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
2 years agoxen/device_tree: add parentheses around macro parameters
Xenia Ragiadakou [Fri, 3 Feb 2023 19:09:07 +0000 (21:09 +0200)]
xen/device_tree: add parentheses around macro parameters

Add parentheses around macro parameters when the precedence and
associativity of the performed operators can lead to unintended order of evaluation.

This is fixing some ECLAIR finding for Misra Rule 20.7.

Link: https://lore.kernel.org/xen-devel/20230203190908.211541-2-burzalodowa@gmail.com/
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
[jgrall: Reworded the commit message]
Acked-by: Julien Grall <jgrall@amazon.com>
2 years agolibs/light: Makefile cleanup
Anthony PERARD [Wed, 8 Feb 2023 08:21:24 +0000 (09:21 +0100)]
libs/light: Makefile cleanup

Rework "libacpi.h" include in "libxl_x86_acpi.c" as to be more
selective about the include path and only add "tools/libacpi/". Also
"libxl_dom.c" don't use "libacpi.h" anymore. Use "-iquote" for libacpi
headers.

Get rid of the weird "$(eval stem =" in the middle of a recipe and use
a make automatic variable "$(*F)" instead.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
2 years agolibs/light: Rework targets prerequisites
Anthony PERARD [Wed, 8 Feb 2023 08:21:11 +0000 (09:21 +0100)]
libs/light: Rework targets prerequisites

No need for $(AUTOSRCS), GNU make can generate them as needed when
trying to build them as needed when trying to build the object. Also,
those two AUTOSRCS don't need to be a prerequisite of "all". As for
the "clean" target, those two files are already removed via "_*.c".

We don't need $(AUTOINCS) either:
- As for both _libxl_save_msgs*.h headers, we are adding more
  selective dependencies so the headers will still be generated as
  needed.
- "clean" rule already delete the _*.h files, so AUTOINCS aren't needed
  there.

"libxl_internal_json.h" doesn't seems to have ever existed, so the
dependency is removed.

Rework objects prerequisites, to have them dependents on either
"libxl.h" or "libxl_internal.h". "libxl.h" is not normally included
directly in the source code as "libxl_internal.h" is used instead, but
we have "libxl.h" as prerequisite of "libxl_internal.h", so generated
headers will still be generated as needed.

Make doesn't need "libxl.h" to generate "testidl.c", "libxl.h" is only
needed later when building "testidl.o". This avoid the need to
regenerate "testidl.c" when only "libxl.h" changed. Also use automatic
variables $< and $@.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
2 years agoxen/riscv: introduce empty <asm/cache.h>
Oleksii Kurochko [Wed, 8 Feb 2023 08:20:39 +0000 (09:20 +0100)]
xen/riscv: introduce empty <asm/cache.h>

To include <xen/lib.h> <asm/cache.h> is required

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: introduce empty <asm/string.h>
Oleksii Kurochko [Wed, 8 Feb 2023 08:20:37 +0000 (09:20 +0100)]
xen/riscv: introduce empty <asm/string.h>

To include <xen/lib.h> <asm/string.h> is required

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: add <asm/riscv_encoding.h header
Oleksii Kurochko [Wed, 8 Feb 2023 08:20:35 +0000 (09:20 +0100)]
xen/riscv: add <asm/riscv_encoding.h header

The following changes were done in Xen code base in comparison with OpenSBI:
  * Remove "#include <sbi/sbi_const.h>" as most of the stuff inside
    it is present in Xen code base.
  * Add macros _UL and _ULL as they were in <sbi/sbi_const.h> before
  * Add SATP32_MODE_SHIFT/SATP64_MODE_SHIFT/SATP_MODE_SHIFT as they will
    be used in riscv/mm.c
  * Add CAUSE_IRQ_FLAG which is going to be used insised exception
    handler
  * Change ulong to unsigned long in macros REG_PTR(...)
  * Change s32 to int32_t

Originally authored by Anup Patel <anup.patel@wdc.com>

Origin: https://github.com/riscv-software-src/opensbi.git c45992cc2b12
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
2 years agoxen/riscv: change ISA to r64G
Oleksii Kurochko [Wed, 8 Feb 2023 08:20:33 +0000 (09:20 +0100)]
xen/riscv: change ISA to r64G

Work with some registers requires csr command which is part of
Zicsr.

Also ISA was changed from r64ima to r64g where G is represented the
“IMAFDZicsr Zifencei” base and extensions so basically it is the same
as it was before plus additional extensions we will need in the
nearest future.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agox86: do not include asm/hvm/support.h when not used
Xenia Ragiadakou [Tue, 7 Feb 2023 14:19:02 +0000 (15:19 +0100)]
x86: do not include asm/hvm/support.h when not used

When none of the declarations and macro definitions in asm/hvm/support.h is
referred in the file, do not include the header.

To fix subsequent build errors, which were not triggered before due to the
indirect inclusion of the missing headers by asm/hvm/support.h, include any
missing headers.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 years agolibxl/x86: use public interface TSC mode definitions
Jan Beulich [Tue, 7 Feb 2023 14:18:18 +0000 (15:18 +0100)]
libxl/x86: use public interface TSC mode definitions

Now that they're properly represented in the public interface, stop
using literal numbers.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
2 years agolibs: Fix auto-generation of version-script for unstable libs
Anthony PERARD [Tue, 7 Feb 2023 14:17:53 +0000 (15:17 +0100)]
libs: Fix auto-generation of version-script for unstable libs

When there isn't a version-script for a shared library (like for
unstable libs), we create one based on the current Xen version. But
that version-script became out-of-date as soon as Xen's version
changes and make as no way to regenerate the version-script on
rebuild.

For unstable libs, we only needs the symver to be different from a
previous release of Xen. There's an option "--default-symver" which
allow to use the soname as symver and as the soname have the Xen
release version, it will be different for every release. With
--default-symver we don't need to generate a version-script.

But we also need to know if there's already an existing version script
, for that we introduce $(version-script) to be used to point to the
path of the existing script. (Guessing if a version script exist for a
stable library with for example $(wildcard) won't work as a file will
exist when building the library without this patch.)

We don't need the version-script unless we are making the shared
library so it is removed from the "all" target.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/time: use public interface TSC mode definitions
Jan Beulich [Mon, 6 Feb 2023 15:04:43 +0000 (16:04 +0100)]
x86/time: use public interface TSC mode definitions

Now that they're properly represented in the public interface, let's do
away with our private #define-s.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/hygon: do not include asm/hvm/support.h when not used
Xenia Ragiadakou [Mon, 6 Feb 2023 15:04:09 +0000 (16:04 +0100)]
x86/hygon: do not include asm/hvm/support.h when not used

Since none of the declarations and macro definitions in asm/hvm/support.h is
referred in x86/cpu/hygon.c, remove the unnecessary include.

To resolve the subsequent build error for implicit declaration of wrmsrl()
and rdmsrl() triggered in asm/spec_ctrl.h, replace asm/msr-index.h with
asm/msr.h in asm/spec_ctrl.h's included headers.

No functional change intended.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 years agotools/symbols: drop asm/types.h inclusion
Jan Beulich [Mon, 6 Feb 2023 15:03:00 +0000 (16:03 +0100)]
tools/symbols: drop asm/types.h inclusion

While this has been there forever, it's not clear to me what it was
(thought to be) needed for. In fact, all three instances of the header
already exclude their entire bodies when __ASSEMBLY__ was defined.
Hence, with no other assembly files including this header, we can at the
same time get rid of those conditionals.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2 years agotools/xenmon: Fix xenmon.py for with python3.x
Bernhard Kaindl [Thu, 2 Feb 2023 17:13:19 +0000 (18:13 +0100)]
tools/xenmon: Fix xenmon.py for with python3.x

Fixes for Py3:
* class Delayed(): file not defined; also an error for pylint -E.  Inherit
  object instead for Py2 compatibility.  Fix DomainInfo() too.
* Inconsistent use of tabs and spaces for indentation (in one block)

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agotools/ocaml/libs: Fix memory/resource leaks with caml_alloc_custom()
Andrew Cooper [Wed, 1 Feb 2023 11:27:42 +0000 (11:27 +0000)]
tools/ocaml/libs: Fix memory/resource leaks with caml_alloc_custom()

All caml_alloc_*() functions can throw exceptions, and longjump out of
context.  If this happens, we leak the xch/xce handle.

Reorder the logic to allocate the the Ocaml object first.

Fixes: 8b3c06a3e545 ("tools/ocaml/xenctrl: OCaml 5 support, fix use-after-free")
Fixes: 22d5affdf0ce ("tools/ocaml/evtchn: OCaml 5 support, fix potential resource leak")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/xc: Don't reference Custom objects with the GC lock released
Edwin Török [Thu, 26 Jan 2023 16:44:05 +0000 (16:44 +0000)]
tools/ocaml/xc: Don't reference Custom objects with the GC lock released

The modification to the _H() macro for Ocaml 5 support introduced a subtle
bug.  From the manual:

  https://ocaml.org/manual/intfc.html#ss:parallel-execution-long-running-c-code

"After caml_release_runtime_system() was called and until
caml_acquire_runtime_system() is called, the C code must not access any OCaml
data, nor call any function of the run-time system, nor call back into OCaml
code."

Previously, the value was a naked C pointer, so dereferencing it wasn't
"accessing any Ocaml data", but the fix to avoid naked C pointers added a
layer of indirection through an Ocaml Custom object, meaning that the common
pattern of using _H() in a blocking section is unsafe.

In order to fix:

 * Drop the _H() macro and replace it with a static inline xch_of_val().
 * Opencode the assignment into Data_custom_val() in the constructors.
 * Rename "value xch" parameters to "value xch_val" so we can consistently
   have "xc_interface *xch" on the stack, and obtain the pointer with the GC
   lock still held.
 * Drop the _D() macro while at it, because it's just pointless indirection.

Fixes: 8b3c06a3e545 ("tools/ocaml/xenctrl: OCaml 5 support, fix use-after-free")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/xc: Don't reference Abstract_Tag objects with the GC lock released
Andrew Cooper [Tue, 31 Jan 2023 17:19:30 +0000 (17:19 +0000)]
tools/ocaml/xc: Don't reference Abstract_Tag objects with the GC lock released

The intf->{addr,len} references in the xc_map_foreign_range() call are unsafe.
From the manual:

  https://ocaml.org/manual/intfc.html#ss:parallel-execution-long-running-c-code

"After caml_release_runtime_system() was called and until
caml_acquire_runtime_system() is called, the C code must not access any OCaml
data, nor call any function of the run-time system, nor call back into OCaml
code."

More than what the manual says, the intf pointer is (potentially) invalidated
by caml_enter_blocking_section() if another thread happens to perform garbage
collection at just the right (wrong) moment.

Rewrite the logic.  There's no need to stash data in the Ocaml object until
the success path at the very end.

Fixes: 8b7ce06a2d34 ("ocaml: Add XC bindings.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/xc: Fix binding for xc_domain_assign_device()
Edwin Török [Thu, 12 Jan 2023 11:38:38 +0000 (11:38 +0000)]
tools/ocaml/xc: Fix binding for xc_domain_assign_device()

The patch adding this binding was plain broken, and unreviewed.  It modified
the C stub to add a 4th parameter without an equivalent adjustment in the
Ocaml side of the bindings.

In 64bit builds, this causes us to dereference whatever dead value is in %rcx
when trying to interpret the rflags parameter.

This has gone unnoticed because Xapi doesn't use this binding (it has its
own), but unbreak the binding by passing RDM_RELAXED unconditionally for
now (matching the libxl default behaviour).

Fixes: 9b34056cb4 ("tools: extend xc_assign_device() to support rdm reservation policy")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/evtchn: Misc cleanup
Andrew Cooper [Mon, 30 Jan 2023 16:37:49 +0000 (16:37 +0000)]
tools/ocaml/evtchn: Misc cleanup

 * Remove local integers when all we're returning is Val_int() of another
   variable.  The CAMLlocal*() can't be optimised automatically, as it's
   registered with the GC.
 * Rename "virq_type" to "virq" and "_port" to "port".
 * In stub_eventchn_pending(), rename 'port' to 'rc', to be consistent with
   all other stubs that return xenevtchn_port_or_error_t.
 * In stub_eventchn_unmask(), check for rc == -1 to be consistent with all
   other stubs.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/evtchn: Don't reference Custom objects with the GC lock released
Edwin Török [Thu, 12 Jan 2023 17:48:29 +0000 (17:48 +0000)]
tools/ocaml/evtchn: Don't reference Custom objects with the GC lock released

The modification to the _H() macro for Ocaml 5 support introduced a subtle
bug.  From the manual:

  https://ocaml.org/manual/intfc.html#ss:parallel-execution-long-running-c-code

"After caml_release_runtime_system() was called and until
caml_acquire_runtime_system() is called, the C code must not access any OCaml
data, nor call any function of the run-time system, nor call back into OCaml
code."

Previously, the value was a naked C pointer, so dereferencing it wasn't
"accessing any Ocaml data", but the fix to avoid naked C pointers added a
layer of indirection through an Ocaml Custom object, meaning that the common
pattern of using _H() in a blocking section is unsafe.

In order to fix:

 * Drop the _H() macro and replace it with a static inline xce_of_val().
 * Opencode the assignment into Data_custom_val() in the two constructors.
 * Rename "value xce" parameters to "value xce_val" so we can consistently
   have "xenevtchn_handle *xce" on the stack, and obtain the pointer with the
   GC lock still held.

Fixes: 22d5affdf0ce ("tools/ocaml/evtchn: OCaml 5 support, fix potential resource leak")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/libs: Allocate the correct amount of memory for Abstract_tag
Andrew Cooper [Tue, 31 Jan 2023 10:59:42 +0000 (10:59 +0000)]
tools/ocaml/libs: Allocate the correct amount of memory for Abstract_tag

caml_alloc() takes units of Wsize (word size), not bytes.  As a consequence,
we're allocating 4 or 8 times too much memory.

Ocaml has a helper, Wsize_bsize(), but it truncates cases which aren't an
exact multiple.  Use a BUILD_BUG_ON() to cover the potential for truncation,
as there's no rounding-up form of the helper.

Fixes: 8b7ce06a2d34 ("ocaml: Add XC bindings.")
Fixes: d3e649277a13 ("ocaml: add mmap bindings implementation.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml/libs: Don't declare stubs as taking void
Edwin Török [Thu, 12 Jan 2023 11:28:29 +0000 (11:28 +0000)]
tools/ocaml/libs: Don't declare stubs as taking void

There is no such thing as an Ocaml function (C stub or otherwise) taking no
parameters.  In the absence of any other parameters, unit is still passed.

This doesn't explode with any ABI we care about, but would malfunction for an
ABI environment such as stdcall.

Fixes: c3afd398ba7f ("ocaml: Add XS bindings.")
Fixes: 8b7ce06a2d34 ("ocaml: Add XC bindings.")
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/oxenstored: validate config file before live update
Edwin Török [Tue, 11 May 2021 15:56:50 +0000 (15:56 +0000)]
tools/oxenstored: validate config file before live update

The configuration file can contain typos or various errors that could prevent
live update from succeeding (e.g. a flag only valid on a different version).
Unknown entries in the config file would be ignored on startup normally,
add a strict --config-test that live-update can use to check that the config file
is valid *for the new binary*.

For compatibility with running old code during live update recognize
--live --help as an equivalent to --config-test.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml: run 'make format' on OCaml files
Edwin Török [Thu, 12 Jan 2023 17:26:39 +0000 (17:26 +0000)]
tools/ocaml: run 'make format' on OCaml files

`git log -p -1 -w` proves the change here is only whitespace.

No functional change.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agotools/ocaml: add 'make format' for OCaml files
Edwin Török [Fri, 2 Dec 2022 17:17:32 +0000 (17:17 +0000)]
tools/ocaml: add 'make format' for OCaml files

Using `ocp-indent` for now to just make minimal modifications in
tabs vs spaces and get the right indentation.

This avoids perpetuating a formatting style that is inconsistent with
the rest of Xen, and that makes preparing and submitting patches more
difficult (OCaml indentation tools usually only support spaces, not tabs).

No functional change.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2 years agobuild: compat-xlat-header.py: optimisation to search for just '{' instead of [{}]
Anthony PERARD [Thu, 19 Jan 2023 15:22:56 +0000 (15:22 +0000)]
build: compat-xlat-header.py: optimisation to search for just '{' instead of [{}]

`fields` and `extrafields` always all the parts of a sub-struct, so
when there is '}', there is always a '{' before it. Also, both are
lists.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: replace get-fields.sh by a python script
Anthony PERARD [Thu, 19 Jan 2023 15:22:55 +0000 (15:22 +0000)]
build: replace get-fields.sh by a python script

The get-fields.sh which generate all the include/compat/.xlat/*.h
headers is quite slow. It takes for example nearly 3 seconds to
generate platform.h on a recent machine, or 2.3 seconds for memory.h.

Rewriting the mix of shell/sed/python into a single python script make
the generation of those file a lot faster.

No functional change, the headers generated are identical.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agobuild: include/compat, remove typedefs handling
Anthony PERARD [Thu, 19 Jan 2023 15:22:54 +0000 (15:22 +0000)]
build: include/compat, remove typedefs handling

Partial revert of c93bd0e6ea2a ("tmem: fix 32-on-64 support")
Since c492e19fdd05 ("xen: remove tmem from hypervisor"), this code
isn't used anymore.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agoChangelog: Add details about new features for SPR
Andrew Cooper [Fri, 20 Jan 2023 21:58:36 +0000 (21:58 +0000)]
Changelog: Add details about new features for SPR

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Henry Wang <Henry.Wang@arm.com>
2 years ago.gitignore: only ignore hidden dependency files
Anthony PERARD [Mon, 6 Feb 2023 07:53:22 +0000 (08:53 +0100)]
.gitignore: only ignore hidden dependency files

The current pattern also ignores directories suffixed with ".d", like:
    tools/hotplug/*/rc.d
    tools/hotplug/*/init.d

Avoid this by only ignoring "hidden" files, for which name starts with
a dot.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2 years agopublic/x86: add TSC defines for cpuid leaf 4
Krister Johansen [Mon, 6 Feb 2023 07:52:31 +0000 (08:52 +0100)]
public/x86: add TSC defines for cpuid leaf 4

Cpuid leaf 4 contains information about how the state of the tsc, its
mode, and some additional information.  A commit that is queued for
linux would like to use this to determine whether the tsc mode has been
set to 'no emulation' in order to make some decisions about which
clocksource is more reliable.

Expose this information in the public API headers so that they can
subsequently be imported into linux and used there.

Link: https://lore.kernel.org/xen-devel/eda8d9f2-3013-1b68-0df8-64d7f13ee35e@suse.com/
Link: https://lore.kernel.org/xen-devel/0835453d-9617-48d5-b2dc-77a2ac298bad@oracle.com/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2 years agoxen/public: move xenstore related doc into 9pfs.h
Juergen Gross [Mon, 6 Feb 2023 07:52:15 +0000 (08:52 +0100)]
xen/public: move xenstore related doc into 9pfs.h

The Xenstore related documentation is currently to be found in
docs/misc/9pfs.pandoc, instead of the related header file
xen/include/public/io/9pfs.h like for most other paravirtualized
device protocols.

There is a comment in the header pointing at the document, but the
given file name is wrong. Additionally such headers are meant to be
copied into consuming projects (Linux kernel, qemu, etc.), so pointing
at a doc file in the Xen git repository isn't really helpful for the
consumers of the header.

This situation is far from ideal, which is already being proved by the
fact that neither qemu nor the Linux kernel are implementing the
device attach/detach protocol correctly.

Change that by moving the Xenstore related 9pfs documentation from
docs/misc/9pfs.pandoc into xen/include/public/io/9pfs.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
2 years agox86/vpmu: remove unused svm and vmx specific headers
Xenia Ragiadakou [Mon, 6 Feb 2023 07:51:39 +0000 (08:51 +0100)]
x86/vpmu: remove unused svm and vmx specific headers

Fixes: 8c20aca6751b ("x86/vPMU: invoke <vendor>_vpmu_initialise() through a hook as well")
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agox86/emulate: remove unused svm specific header
Xenia Ragiadakou [Mon, 6 Feb 2023 07:50:32 +0000 (08:50 +0100)]
x86/emulate: remove unused svm specific header

Fixes: 2191599bacb7 ("x86/emul: Simplfy emulation state setup")
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2 years agotools/python: change 's#' size type for Python >= 3.10
Marek Marczykowski-Górecki [Mon, 6 Feb 2023 07:50:13 +0000 (08:50 +0100)]
tools/python: change 's#' size type for Python >= 3.10

Python < 3.10 by default uses 'int' type for data+size string types
(s#), unless PY_SSIZE_T_CLEAN is defined - in which case it uses
Py_ssize_t. The former behavior was removed in Python 3.10 and now it's
required to define PY_SSIZE_T_CLEAN before including Python.h, and using
Py_ssize_t for the length argument. The PY_SSIZE_T_CLEAN behavior is
supported since Python 2.5.

Adjust bindings accordingly.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
2 years agoxen/cppcheck: add parameter to skip given MISRA rules
Luca Fancellu [Mon, 30 Jan 2023 11:01:32 +0000 (11:01 +0000)]
xen/cppcheck: add parameter to skip given MISRA rules

Add parameter to skip the passed MISRA rules during the cppcheck
analysis, the rules are specified as a list of comma separated
rules with the MISRA number notation (e.g. 1.1,1.3,...).

Modify convert_misra_doc.py script to take an extra parameter
giving a list of MISRA rule to be skipped, comma separated.
While there, fix some typos in the help and print functions.

Modify settings.py and cppcheck_analysis.py to have a new
parameter (--cppcheck-skip-rules) used to specify a list of
MISRA rule to be skipped during the cppcheck analysis.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2 years agoxen/cppcheck: sort alphabetically cppcheck report entries
Luca Fancellu [Mon, 30 Jan 2023 11:01:31 +0000 (11:01 +0000)]
xen/cppcheck: sort alphabetically cppcheck report entries

Sort alphabetically cppcheck report entries when producing the text
report, this will help comparing different reports and will group
together findings from the same file.

The sort operation is performed with two criteria, the first one is
sorting by misra rule, the second one is sorting by file.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
[stefano: add black line for code style]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>