Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] sync misc update from mainline-v6.7#1930

Merged
opsiff merged 4 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-06-29-update
Jun 29, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] sync misc update from mainline-v6.7#1930
opsiff merged 4 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-06-29-update

Conversation

@opsiff

@opsiff opsiff commented Jun 29, 2026

Copy link
Copy Markdown
Member

KVM: x86: Force TLB flush on userspace changes to special registers
afs: Remove whitespace before most ')' from the trace header
nvmet-fc: Annotate struct nvmet_fc_tgt_queue with __counted_by
nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]

Summary by Sourcery

Sync x86 KVM special-register handling and NVMe FC target queue annotations with upstream, and clean up AFS trace event definitions.

Bug Fixes:

  • Ensure x86 KVM forces a guest TLB flush whenever userspace changes special registers that require an MMU context reset.

Enhancements:

  • Align NVMe FC target queue flexible-array annotation with upstream by moving __counted_by to a comment on the fod[] member.
  • Normalize AFS trace event header field declarations by removing extraneous whitespace to match upstream style.

mmhal and others added 4 commits June 29, 2026 10:56
mainline inclusion
from mainline-v6.7-rc1
category: performance

Userspace can directly modify the content of vCPU's CR0, CR3, and CR4 via
KVM_SYNC_X86_SREGS and KVM_SET_SREGS{,2}. Make sure that KVM flushes guest
TLB entries and paging-structure caches if a (partial) guest TLB flush is
architecturally required based on the CRn changes.  To keep things simple,
flush whenever KVM resets the MMU context, i.e. if any bits in CR0, CR3,
CR4, or EFER are modified.  This is extreme overkill, but stuffing state
from userspace is not such a hot path that preserving guest TLB state is a
priority.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20230814222358.707877-3-mhal@rbox.co
[sean: call out that the flushing on MMU context resets is for simplicity]
Signed-off-by: Sean Christopherson <seanjc@google.com>
(cherry picked from commit 4346db6)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.8-rc1
category: performance

checkpatch objects to whitespace before ')', so remove most of it from the
afs trace header.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
(cherry picked from commit a790c25)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.7-rc1
category: performance

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct
nvmet_fc_tgt_queue. Additionally, since the element count member must
be set before accessing the annotated flexible array member, move its
initialization earlier.

Cc: James Smart <james.smart@broadcom.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit ccd3129)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
mainline inclusion
from mainline-v6.10-rc6
category: bugfix

Work for __counted_by on generic pointers in structures (not just
flexible array members) has started landing in Clang 19 (current tip of
tree). During the development of this feature, a restriction was added
to __counted_by to prevent the flexible array member's element type from
including a flexible array member itself such as:

  struct foo {
    int count;
    char buf[];
  };

  struct bar {
    int count;
    struct foo data[] __counted_by(count);
  };

because the size of data cannot be calculated with the standard array
size formula:

  sizeof(struct foo) * count

This restriction was downgraded to a warning but due to CONFIG_WERROR,
it can still break the build. The application of __counted_by on the fod
member of 'struct nvmet_fc_tgt_queue' triggers this restriction,
resulting in:

  drivers/nvme/target/fc.c:151:2: error: 'counted_by' should not be applied to an array with element of unknown size because 'struct nvmet_fc_fcp_iod' is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size]
    151 |         struct nvmet_fc_fcp_iod         fod[] __counted_by(sqsize);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

Remove this use of __counted_by to fix the warning/error. However,
rather than remove it altogether, leave it commented, as it may be
possible to support this in future compiler releases.

Cc: stable@vger.kernel.org
Closes: ClangBuiltLinux/linux#2027
Fixes: ccd3129 ("nvmet-fc: Annotate struct nvmet_fc_tgt_queue with __counted_by")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit 440e205)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai

sourcery-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Syncs several upstream changes: enforces a guest TLB flush when userspace updates special registers in KVM, cleans up afs tracepoint macros formatting, and adjusts the nvmet-fc target queue’s fod[] annotation to align with mainline __counted_by usage.

Sequence diagram for KVM TLB flush on userspace special register updates

sequenceDiagram
    actor Userspace
    participant KVM

    Userspace->>KVM: __set_sregs
    alt mmu_reset_needed
        KVM->>KVM: kvm_mmu_reset_context
        KVM->>KVM: kvm_make_request KVM_REQ_TLB_FLUSH_GUEST
    end

    Userspace->>KVM: __set_sregs2
    alt mmu_reset_needed
        KVM->>KVM: kvm_mmu_reset_context
        KVM->>KVM: kvm_make_request KVM_REQ_TLB_FLUSH_GUEST
    end
Loading

File-Level Changes

Change Details Files
Enforce TLB flush when userspace modifies special registers via KVM set_sregs/set_sregs2, ensuring guest MMU state is fully updated after a context reset.
  • Detect mmu_reset_needed in __set_sregs and __set_sregs2 and, when set, trigger both kvm_mmu_reset_context and a guest TLB flush request
  • Use kvm_make_request with KVM_REQ_TLB_FLUSH_GUEST to queue the flush after MMU context reset
arch/x86/kvm/x86.c
Normalize afs tracepoint field macro formatting by removing trailing whitespace before closing parentheses.
  • Update __field and __array usages in TRACE_EVENT definitions to drop extra spaces before ')' while keeping field lists and types unchanged
  • Ensure no semantic changes to afs tracing; only header style is modified
include/trace/events/afs.h
Align nvmet-fc target queue fod[] annotation with upstream by placing __counted_by as a comment next to the flexible array member instead of an attribute on the member.
  • Remove __counted_by attribute from the flexible array member declaration to avoid incorrect usage on fod[]
  • Add a comment-based __counted_by(sqsize) note adjacent to fod[] to document its size relationship without changing ABI
drivers/nvme/target/fc.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot deepin-ci-robot requested a review from shy129 June 29, 2026 10:17
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@Avenger-285714 Avenger-285714 self-requested a review June 29, 2026 13:29
@opsiff opsiff requested a review from dongert June 29, 2026 15:28
@opsiff opsiff merged commit 3fbcd39 into deepin-community:linux-6.6.y Jun 29, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants