Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux-6.6.y] Add support for ZXPAUSE instruction #276

Merged

Conversation

leoliu-oc
Copy link
Contributor

Includes:

  1. x86/delay: add support for Zhaoxin ZXPAUSE instruction
  2. KVM: x86: Introduce support for Zhaoxin ZXPAUSE instruction

zhaoxin inclusion
category: feature

-------------------

ZXPAUSE instructs the processor to enter an implementation-dependent
optimized state. The instruction execution wakes up when the time-stamp
counter reaches or exceeds the implicit EDX:EAX 64-bit input value.
The instruction execution also wakes up due to the expiration of
the operating system time-limit or by an external interrupt.

ZXPAUSE is available on processors with X86_FEATURE_ZXPAUSE.
ZXPAUSE allows the processor to enter a light-weight power/performance
optimized state (C0.1 state) for a period specified by the instruction
or until the system time limit.

MSR_ZX_PAUSE_CONTROL MSR register allows the OS to enable/disable C0.2 on
the processor and to set the maximum time the processor can reside in C0.1
or C0.2. By default C0.2 is disabled.

A sysfs interface to adjust the time and the C0.2 enablement is provided in
a follow up change.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
zhaoxin inclusion
category: feature

--------------------

This patch introduces support for the ZXPAUSE instruction, a new addition
akin to Intel's TPAUSE. Two primary distinctions set apart ZXPAUSE from
TPAUSE:

1. ZXPAUSE utilizes a delta tsc, determined from the lesser value between
   (MSR_ZX_PAUSE_CONTROL[31:2] << 2) and the EDX:EAX input to the ZXPAUSE
   instruction, subtracted from the current tsc value.

   In contrast, TPAUSE employs a target tsc, computed from the lesser
   value between (MSR_IA32_UMWAIT_CONTROL[31:2] << 2) and the EDX:EAX
   input to the TPAUSE instruction.

2. As of now, ZXPAUSE exclusively supports the C0.1 optimization state,
   whereas TPAUSE potentially extends support to both C0.1 and C0.2.

Successful integration of this patch hinges on QEMU's backing for ZXPAUSE,
a contribution we're currently forwarding to QEMU. It also requires the
preceding patch in this patchset, which offers Linux kernel support for
ZXPAUSE.

The choice of the name "vmx->msr_ia32_umwait_control" is deliberate. In
patches for other Linux versions (e.g., 5.5), a
"vmx->msr_ia32_umwait_control" already exists. By sharing this variable
name with Intel, it ensures compatibility. The difference is merely
software-based and poses no real-world conflicts.

Currently, if the Guest writes to the ZXPAUSE/TPAUSE CONTROL MSR, we
simply bypass the WRMSR instruction. If the Guest attempts to use
ZXPAUSE/TPAUSE to transition the vCPU into an optimized state, it will
succeed, with the duration of the optimized state being the value passed
in EDX:EAX.

Of course, this state can be interrupted by external interrupts and other
events specified in the specification.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
@deepin-ci-robot
Copy link

Hi @leoliu-oc. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@opsiff opsiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ok-to-test

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: opsiff
Once this PR has been reviewed and has the lgtm label, please assign goldendeng for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff
Copy link
Member

opsiff commented Jul 1, 2024

/ok-to-test

@opsiff opsiff merged commit 7e9b2be into deepin-community:linux-6.6.y Jul 1, 2024
3 checks passed
@deepin-ci-robot
Copy link

deepin pr auto review

Add Zhaoxin extended VMCS capabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants