uv.c (ab73b29efd36f8916c6cc9954e912c4723c9a1b0) uv.c (d6c8097803cbc3bb8d875baef542e6d77d10c203)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Common Ultravisor functions and initialization
4 *
5 * Copyright IBM Corp. 2019, 2024
6 */
7#define KMSG_COMPONENT "prot_virt"
8#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt

--- 122 unchanged lines hidden (view full) ---

131
132/*
133 * The caller must already hold a reference to the folio
134 */
135int uv_destroy_folio(struct folio *folio)
136{
137 int rc;
138
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Common Ultravisor functions and initialization
4 *
5 * Copyright IBM Corp. 2019, 2024
6 */
7#define KMSG_COMPONENT "prot_virt"
8#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt

--- 122 unchanged lines hidden (view full) ---

131
132/*
133 * The caller must already hold a reference to the folio
134 */
135int uv_destroy_folio(struct folio *folio)
136{
137 int rc;
138
139 /* See gmap_make_secure(): large folios cannot be secure */
139 /* Large folios cannot be secure */
140 if (unlikely(folio_test_large(folio)))
141 return 0;
142
143 folio_get(folio);
144 rc = uv_destroy(folio_to_phys(folio));
145 if (!rc)
146 clear_bit(PG_arch_1, &folio->flags);
147 folio_put(folio);

--- 32 unchanged lines hidden (view full) ---

180
181/*
182 * The caller must already hold a reference to the folio.
183 */
184int uv_convert_from_secure_folio(struct folio *folio)
185{
186 int rc;
187
140 if (unlikely(folio_test_large(folio)))
141 return 0;
142
143 folio_get(folio);
144 rc = uv_destroy(folio_to_phys(folio));
145 if (!rc)
146 clear_bit(PG_arch_1, &folio->flags);
147 folio_put(folio);

--- 32 unchanged lines hidden (view full) ---

180
181/*
182 * The caller must already hold a reference to the folio.
183 */
184int uv_convert_from_secure_folio(struct folio *folio)
185{
186 int rc;
187
188 /* See gmap_make_secure(): large folios cannot be secure */
188 /* Large folios cannot be secure */
189 if (unlikely(folio_test_large(folio)))
190 return 0;
191
192 folio_get(folio);
193 rc = uv_convert_from_secure(folio_to_phys(folio));
194 if (!rc)
195 clear_bit(PG_arch_1, &folio->flags);
196 folio_put(folio);

--- 260 unchanged lines hidden (view full) ---

457 folio_put(folio);
458
459 return rc;
460}
461EXPORT_SYMBOL_GPL(make_hva_secure);
462
463/*
464 * To be called with the folio locked or with an extra reference! This will
189 if (unlikely(folio_test_large(folio)))
190 return 0;
191
192 folio_get(folio);
193 rc = uv_convert_from_secure(folio_to_phys(folio));
194 if (!rc)
195 clear_bit(PG_arch_1, &folio->flags);
196 folio_put(folio);

--- 260 unchanged lines hidden (view full) ---

457 folio_put(folio);
458
459 return rc;
460}
461EXPORT_SYMBOL_GPL(make_hva_secure);
462
463/*
464 * To be called with the folio locked or with an extra reference! This will
465 * prevent gmap_make_secure from touching the folio concurrently. Having 2
466 * parallel arch_make_folio_accessible is fine, as the UV calls will become a
467 * no-op if the folio is already exported.
465 * prevent kvm_s390_pv_make_secure() from touching the folio concurrently.
466 * Having 2 parallel arch_make_folio_accessible is fine, as the UV calls will
467 * become a no-op if the folio is already exported.
468 */
469int arch_make_folio_accessible(struct folio *folio)
470{
471 int rc = 0;
472
468 */
469int arch_make_folio_accessible(struct folio *folio)
470{
471 int rc = 0;
472
473 /* See gmap_make_secure(): large folios cannot be secure */
473 /* Large folios cannot be secure */
474 if (unlikely(folio_test_large(folio)))
475 return 0;
476
477 /*
478 * PG_arch_1 is used in 2 places:
479 * 1. for storage keys of hugetlb folios and KVM
480 * 2. As an indication that this small folio might be secure. This can
481 * overindicate, e.g. we set the bit before calling

--- 487 unchanged lines hidden ---
474 if (unlikely(folio_test_large(folio)))
475 return 0;
476
477 /*
478 * PG_arch_1 is used in 2 places:
479 * 1. for storage keys of hugetlb folios and KVM
480 * 2. As an indication that this small folio might be secure. This can
481 * overindicate, e.g. we set the bit before calling

--- 487 unchanged lines hidden ---