[UBUNTU 22.04] s390/cpum_cf: make crypto counters upward compatible

Bug #2074380 reported by bugproxy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu on IBM z Systems
Fix Committed
High
Skipper Bug Screeners
linux (Ubuntu)
Fix Released
Undecided
Unassigned
Jammy
Fix Committed
High
Canonical Kernel Team
Noble
Fix Committed
High
Canonical Kernel Team

Bug Description

SRU Justification:

[ Impact ]

 * The CPU Measurement Facility (CPU MF) crypto counter set
   is not listed in the device sysfs tree - it's not exported
   in the sysfs directory /sys/devices/cpum_cf/events.

 * The attribute files for each CPU-MF counter defined
   in the crypto counter set is missing.

 * This is caused by the counter second version number of CPU MF
   hardware being incremented on new machines.

 * This causes a sanity check to fail,
   but the counters are supported by hardware.

 * The solution is to remove the upper limit in counter second
   version number check.

[ Fix ]

 * f10933cbd2df f10933cbd2dfddf6273698a45f76db9bafd8150f
   "s390/cpum_cf: make crypto counters upward compatible across machine types"

 * The fix was upstream accepted with kernel v6.10(-rc1).

 * Upstream commit applies cleanly on noble master-next,
   but needed to be backported to jammy master-next due to different code
   and context in kernel 5.15.

[ Test Plan ]

 * Run the following commands on a new machine generation:
   (hence only doable by IBM)
   # ls -l /sys/devices/cpum_cf/events/ | grep AES

 * If the output is empty than this patch is required.

 * With a patched kernel the output should be like:
   # ls /sys/devices/cpum_cf/events/ | grep AES
   AES_BLOCKED_CYCLES
   AES_BLOCKED_FUNCTIONS
   AES_CYCLES
   AES_FUNCTIONS

[ Where problems could occur ]

 * This affects s390x only - CPU MF is s390-specific,
   and only s390 specific code is modified.

 * And it furthermore is limited to the crypto counter set
   of CPU MF.

 * So any impact is likely limited to hardware crypto counters
   on s390x only.

 * In s390/kernel/perf_cpum_cf.c the else if case got changed from
   explicitly checking for 6 or 7 to >= 6 which seems to require
   attention for future 8 and more cases.

 * In s390/kernel/perf_cpum_cf_events.c the switch (ci.csvn) statement
   was changed to an if / else if with similar logic.
   Again attentioin for any potential future cases >= 8.

 * It does not look like currently used cases (1..5 and 6..7)
   are affected by the modification, just >7.

 * Test build of patched jammy and noble s390x kernels were build
   and are avaiable here:
   https://launchpad.net/~fheimes/+archive/ubuntu/lp2074380

[ Other Info ]

 * Since the code/fix was upstream accepted with kernel v6.10(-rc1)
   it does not affect the current development release oracular.

 * This SRU can also be seen under the umbrella of new
    hardware enablement.

 * Since it requires special hw, the verification needs to be
   done by IBM.

__________

Description: kernel: s390/cpum_cf: make crypto counters upward compatible

Symptom: The CPU Measurement facility crypto counter set is not
               listed in the device sysfs tree.

Problem: The CPU Measurement facility crypto counter set is not
               exported in the sysfs directory
               /sys/devices/cpum_cf/events.
               The attribute files for each CPU-MF counter defined
               in the crypto counter set is missing. This is caused
               by the counter second version number of the CPU
               Measurement Facility hardware being incremented on
               new machines. This causes a sanity check to fail,
               but the counters are supported by hardware.

Solution: Remove upper limit in counter second version number
               check.

Reproduction: Run command on a new machine generation:
                # ls -l /sys/devices/cpum_cf/events/ | grep AES
                #
               If the output is empty than this patch is required.
               The output should be:
                # ls /sys/devices/cpum_cf/events/ | grep AES
                AES_BLOCKED_CYCLES
                AES_BLOCKED_FUNCTIONS
                AES_CYCLES
                AES_FUNCTIONS
                #

Upstream-ID of fix: f10933cbd2dfddf6273698a45f76db9bafd8150f

bugproxy (bugproxy)
tags: added: architecture-s39064 bugnameltc-207993 severity-high targetmilestone-inin---
Changed in ubuntu:
assignee: nobody → Skipper Bug Screeners (skipper-screen-team)
affects: ubuntu → linux (Ubuntu)
Frank Heimes (fheimes)
Changed in linux (Ubuntu):
status: New → Fix Released
Changed in ubuntu-z-systems:
importance: Undecided → High
Changed in linux (Ubuntu Jammy):
importance: Undecided → High
Changed in linux (Ubuntu Noble):
importance: Undecided → High
Changed in ubuntu-z-systems:
assignee: nobody → Skipper Bug Screeners (skipper-screen-team)
Changed in linux (Ubuntu):
assignee: Skipper Bug Screeners (skipper-screen-team) → nobody
Revision history for this message
Frank Heimes (fheimes) wrote :

The commit applies fine to the noble master-next tree (kernel 6.8),
and a test build was triggered here: https://launchpad.net/~fheimes/+archive/ubuntu/lp2074380

However, the cpumf code in jammy master-next (kernel 5.15) is quite different.
git blame tells me that probably the following commits are needed as well:
111783-1a33aee1dc24 s390/cpum_cf: remove function validate_ctr_auth() by inline code
111784-9ae9b868aeaa s390/cpum_cf: provide counter number to validate_ctr_version()
111785:46c4d945ea1f s390/cpum_cf: introduce static CPU counter facility information
but they (first of all 46c4d945ea1f) also do not apply cleanly.

Would you please let us know a minimal set of patches (based on your insights of the code) that let us apply f10933cbd2df to the jammy master-next tree (git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy --branch master-next --single-branch)
or alternatively a backport of f10933cbd2df to this tree?

Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2024-08-01 04:53 EDT-------
After a fews tries to fix up the prereq patches, I decided to do a backport
of the patch in question. I have used:

$ git branch
master
* master-next
master-prep
z17-toleration
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "master-prep"]
remote = origin
merge = refs/heads/master-prep
[branch "master-next"]
remote = origin
merge = refs/heads/master-next
$

I hope this was the right code base.

Revision history for this message
bugproxy (bugproxy) wrote : s390/cpum_cf: make crypto counters upward compatible across machine types for jammy-master-next tree

------- Comment (attachment only) From <email address hidden> 2024-08-01 04:49 EDT-------

Revision history for this message
Frank Heimes (fheimes) wrote : Re: [UBUNTU 22.04] kernel: s390/cpum_cf: make crypto counters upward compatible

Hello Thomas, thank you!
Was also my impression that a backport is probably best.
And the backport applies cleanly on jammy master-next (so yes, that is what we have to use for the next and upcoming kernel of an Ubuntu release).

Proceeding now with the kernel SRU ...

Frank Heimes (fheimes)
Changed in linux (Ubuntu Jammy):
status: New → In Progress
Changed in linux (Ubuntu Noble):
status: New → In Progress
Changed in ubuntu-z-systems:
status: New → In Progress
description: updated
Changed in linux (Ubuntu Jammy):
assignee: nobody → Frank Heimes (fheimes)
Changed in linux (Ubuntu Noble):
assignee: nobody → Frank Heimes (fheimes)
Frank Heimes (fheimes)
description: updated
summary: - [UBUNTU 22.04] kernel: s390/cpum_cf: make crypto counters upward
- compatible
+ [UBUNTU 22.04] s390/cpum_cf: make crypto counters upward compatible
Revision history for this message
Frank Heimes (fheimes) wrote :
Changed in linux (Ubuntu Jammy):
assignee: Frank Heimes (fheimes) → Canonical Kernel Team (canonical-kernel-team)
Changed in linux (Ubuntu Noble):
assignee: Frank Heimes (fheimes) → Canonical Kernel Team (canonical-kernel-team)
Changed in linux (Ubuntu Noble):
status: In Progress → Fix Committed
Changed in linux (Ubuntu Jammy):
status: In Progress → Fix Committed
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.