diff mbox series

virt: sev-guest: Mark driver struct with __refdata to prevent section mismatch

Message ID 4a81b0e87728a58904283e2d1f18f73abc69c2a1.1711748999.git.u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series virt: sev-guest: Mark driver struct with __refdata to prevent section mismatch | expand

Commit Message

Uwe Kleine-König March 29, 2024, 9:54 p.m. UTC
As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent the following section mismatch warning

	WARNING: modpost: drivers/virt/coco/sev-guest/sev-guest: section mismatch in reference: sev_guest_driver+0x10 (section: .data) -> sev_guest_remove (section: .exit.text)

that triggers on an allmodconfig W=1 build.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/virt/coco/sev-guest/sev-guest.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2

Comments

Kuppuswamy Sathyanarayanan March 30, 2024, 12:16 a.m. UTC | #1
On 3/29/24 2:54 PM, Uwe Kleine-König wrote:
> As described in the added code comment, a reference to .exit.text is ok
> for drivers registered via module_platform_driver_probe(). Make this
> explicit to prevent the following section mismatch warning
>
> 	WARNING: modpost: drivers/virt/coco/sev-guest/sev-guest: section mismatch in reference: sev_guest_driver+0x10 (section: .data) -> sev_guest_remove (section: .exit.text)
>
> that triggers on an allmodconfig W=1 build.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---

LGTM

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>  drivers/virt/coco/sev-guest/sev-guest.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
> index 87f241825bc3..1af68065b3d9 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.c
> +++ b/drivers/virt/coco/sev-guest/sev-guest.c
> @@ -1009,8 +1009,13 @@ static void __exit sev_guest_remove(struct platform_device *pdev)
>   * This driver is meant to be a common SEV guest interface driver and to
>   * support any SEV guest API. As such, even though it has been introduced
>   * with the SEV-SNP support, it is named "sev-guest".
> + *
> + * sev_guest_remove() lives in .exit.text. For drivers registered via
> + * module_platform_driver_probe() this is ok because they cannot get unbound at
> + * runtime. So mark the driver struct with __refdata to prevent modpost
> + * triggering a section mismatch warning.
>   */
> -static struct platform_driver sev_guest_driver = {
> +static struct platform_driver sev_guest_driver __refdata = {
>  	.remove_new	= __exit_p(sev_guest_remove),
>  	.driver		= {
>  		.name = "sev-guest",
> base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
Uwe Kleine-König April 15, 2024, 2:39 p.m. UTC | #2
Hello,

On Fri, Mar 29, 2024 at 10:54:41PM +0100, Uwe Kleine-König wrote:
> As described in the added code comment, a reference to .exit.text is ok
> for drivers registered via module_platform_driver_probe(). Make this
> explicit to prevent the following section mismatch warning
> 
> 	WARNING: modpost: drivers/virt/coco/sev-guest/sev-guest: section mismatch in reference: sev_guest_driver+0x10 (section: .data) -> sev_guest_remove (section: .exit.text)
> 
> that triggers on an allmodconfig W=1 build.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I'd like to enable these warnings even for W=0 builds, so it would be
great to get it into the main line soon.

If you apply it, please notice that I fat-fingered the parameters to git
send-email and it was sent in a thread. So (assuming you're using b4)
you'd need:

        b4 am -P _ 4a81b0e87728a58904283e2d1f18f73abc69c2a1.1711748999.git.u.kleine-koenig@pengutronix.de

Best regards
Uwe
Tom Lendacky April 15, 2024, 9:53 p.m. UTC | #3
On 3/29/24 16:54, Uwe Kleine-König wrote:
> As described in the added code comment, a reference to .exit.text is ok
> for drivers registered via module_platform_driver_probe(). Make this
> explicit to prevent the following section mismatch warning
> 
> 	WARNING: modpost: drivers/virt/coco/sev-guest/sev-guest: section mismatch in reference: sev_guest_driver+0x10 (section: .data) -> sev_guest_remove (section: .exit.text)
> 
> that triggers on an allmodconfig W=1 build.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>   drivers/virt/coco/sev-guest/sev-guest.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
> index 87f241825bc3..1af68065b3d9 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.c
> +++ b/drivers/virt/coco/sev-guest/sev-guest.c
> @@ -1009,8 +1009,13 @@ static void __exit sev_guest_remove(struct platform_device *pdev)
>    * This driver is meant to be a common SEV guest interface driver and to
>    * support any SEV guest API. As such, even though it has been introduced
>    * with the SEV-SNP support, it is named "sev-guest".
> + *
> + * sev_guest_remove() lives in .exit.text. For drivers registered via
> + * module_platform_driver_probe() this is ok because they cannot get unbound at
> + * runtime. So mark the driver struct with __refdata to prevent modpost
> + * triggering a section mismatch warning.
>    */
> -static struct platform_driver sev_guest_driver = {
> +static struct platform_driver sev_guest_driver __refdata = {
>   	.remove_new	= __exit_p(sev_guest_remove),
>   	.driver		= {
>   		.name = "sev-guest",
> base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
Uwe Kleine-König April 29, 2024, 8:32 p.m. UTC | #4
On Mon, Apr 15, 2024 at 04:39:32PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Fri, Mar 29, 2024 at 10:54:41PM +0100, Uwe Kleine-König wrote:
> > As described in the added code comment, a reference to .exit.text is ok
> > for drivers registered via module_platform_driver_probe(). Make this
> > explicit to prevent the following section mismatch warning
> > 
> > 	WARNING: modpost: drivers/virt/coco/sev-guest/sev-guest: section mismatch in reference: sev_guest_driver+0x10 (section: .data) -> sev_guest_remove (section: .exit.text)
> > 
> > that triggers on an allmodconfig W=1 build.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> I'd like to enable these warnings even for W=0 builds, so it would be
> great to get it into the main line soon.
> 
> If you apply it, please notice that I fat-fingered the parameters to git
> send-email and it was sent in a thread. So (assuming you're using b4)
> you'd need:
> 
>         b4 am -P _ 4a81b0e87728a58904283e2d1f18f73abc69c2a1.1711748999.git.u.kleine-koenig@pengutronix.de

This patch didn't make it into next up to now. Is there a chance to get
it into v6.10-rc1?

Best regards
Uwe
diff mbox series

Patch

diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index 87f241825bc3..1af68065b3d9 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -1009,8 +1009,13 @@  static void __exit sev_guest_remove(struct platform_device *pdev)
  * This driver is meant to be a common SEV guest interface driver and to
  * support any SEV guest API. As such, even though it has been introduced
  * with the SEV-SNP support, it is named "sev-guest".
+ *
+ * sev_guest_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
  */
-static struct platform_driver sev_guest_driver = {
+static struct platform_driver sev_guest_driver __refdata = {
 	.remove_new	= __exit_p(sev_guest_remove),
 	.driver		= {
 		.name = "sev-guest",