-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Enable CEX based LUKS encryption #423
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| [localhost] | ||
| 127.0.0.1 ansible_connection=local | ||
| 127.0.0.1 ansible_connection=local ansible_become_password= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
|
|
||
| - name: Set cex_cards from cex_uuid_map values (uuid:domain only) | ||
| set_fact: | ||
| cex_cards: "{{ cex_uuid_map.values() | list | unique }}" | ||
|
|
||
| - name: Debug final list of CEX UUID assignments | ||
| debug: | ||
| var: cex_cards | ||
|
|
||
| - name: Create VFIO assignment script for all CEX cards | ||
| template: | ||
| src: assign_cards.sh.j2 | ||
| dest: /tmp/assign_all_cex_cards.sh | ||
| mode: '0755' | ||
|
|
||
| - name: Execute VFIO assignment script | ||
| shell: /tmp/assign_all_cex_cards.sh | ||
| args: | ||
| executable: /bin/bash | ||
|
|
||
| - name: Housekeep temporary assignment script | ||
| file: | ||
| path: /tmp/assign_all_cex_cards.sh | ||
| state: absent | ||
|
|
||
| - name: Initialize empty cex_hostdev_map | ||
| set_fact: | ||
| cex_hostdev_map: {} | ||
|
|
||
| - name: Populate cex_hostdev_map with mdev format | ||
| set_fact: | ||
| cex_hostdev_map: "{{ cex_hostdev_map | combine({ item.key : 'mdev_' + (item.value.split(':')[0] | regex_replace('-', '_')) + '_matrix' }) }}" | ||
|
Check warning on line 33 in roles/configure_cex/tasks/main.yaml
|
||
| loop: "{{ cex_uuid_map | dict2items }}" | ||
|
|
||
|
|
||
| - name: Save cex_hostdev_map to a file for reuse | ||
| copy: | ||
| dest: "/root/.cex_hostdev_map.json" | ||
| content: "{{ cex_hostdev_map | to_nice_json }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
| # Reference document for the cex configuration in zKVM | ||
| # https://www.ibm.com/docs/en/linux-on-systems?topic=management-configuring-crypto-express-adapters-kvm-guests | ||
|
|
||
| # Configure each CEX card | ||
| {% for entry in cex_cards %} | ||
| {% set uuid = entry.split(':')[0] %} | ||
| {% set matrix_val = entry.split(':')[1] %} | ||
| {% set adapter = matrix_val.split('.')[0] %} | ||
| {% set domain = matrix_val.split('.')[1] %} | ||
|
|
||
| uuid="{{ uuid }}" | ||
| matrix_val="{{ matrix_val }}" | ||
| adapter="{{ adapter }}" | ||
| domain="{{ domain }}" | ||
|
|
||
| uuid_path="/sys/devices/vfio_ap/matrix/$uuid" | ||
| matrix_file="$uuid_path/matrix" | ||
|
|
||
| if [ -d "$uuid_path" ]; then | ||
| if grep -q "{{ matrix_val }}" "$matrix_file" 2>/dev/null; then | ||
| echo "[INFO] UUID $uuid already configured with matrix {{ matrix_val }} — skipping." | ||
| else | ||
| echo "[WARN] UUID $uuid exists, but matrix entry '{{ matrix_val }}' not found!" | ||
| echo "[WARN] Please reboot the node and try again." | ||
| exit 1 | ||
| fi | ||
| else | ||
| modprobe vfio_ap | ||
| echo 0x0 > /sys/bus/ap/apmask | ||
| echo 0x0 > /sys/bus/ap/aqmask | ||
| echo "[INFO] Creating UUID $uuid with adapter $adapter and domain $domain" | ||
| echo "$uuid" > /sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/create | ||
| echo "0x$adapter" > "$uuid_path/assign_adapter" | ||
| echo "0x$domain" > "$uuid_path/assign_domain" | ||
| fi | ||
|
|
||
| {% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| variant: openshift | ||
| version: {{ butane_default["version"] }} | ||
| metadata: | ||
| name: {{ node_role }}-luks-storage | ||
| labels: | ||
| machineconfiguration.openshift.io/role: {{ node_role }} | ||
|
|
||
| openshift: | ||
| fips: true | ||
| kernel_arguments: | ||
| - rd.luks.key=/etc/luks/cex.key | ||
|
|
||
| {% if cex_device in ['dasd', 'virt'] %} | ||
| boot_device: | ||
| layout: {{ butane_default[cex_device].layout }} | ||
| luks: | ||
| device: {{ butane_default[cex_device].device }} | ||
| cex: | ||
| enabled: true | ||
|
|
||
| {% elif cex_device == 'fcp' %} | ||
| storage: | ||
| filesystems: | ||
| - device: /dev/mapper/root | ||
| format: xfs | ||
| label: root | ||
| wipe_filesystem: true | ||
| luks: | ||
| - cex: | ||
| enabled: true | ||
| device: {{ butane_default[cex_device].device }} | ||
| label: luks-root | ||
| name: root | ||
| wipe_volume: true | ||
| {% endif %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.