@@ -635,4 +635,152 @@ TEST_F(uc_kvm, uc_skey)
635635 uc_assert_diag44 (self );
636636}
637637
638+ static char uc_flic_b [PAGE_SIZE ];
639+ static struct kvm_s390_io_adapter uc_flic_ioa = { .id = 0 };
640+ static struct kvm_s390_io_adapter_req uc_flic_ioam = { .id = 0 };
641+ static struct kvm_s390_ais_req uc_flic_asim = { .isc = 0 };
642+ static struct kvm_s390_ais_all uc_flic_asima = { .simm = 0 };
643+ static struct uc_flic_attr_test {
644+ char * name ;
645+ struct kvm_device_attr a ;
646+ int hasrc ;
647+ int geterrno ;
648+ int seterrno ;
649+ } uc_flic_attr_tests [] = {
650+ {
651+ .name = "KVM_DEV_FLIC_GET_ALL_IRQS" ,
652+ .seterrno = EINVAL ,
653+ .a = {
654+ .group = KVM_DEV_FLIC_GET_ALL_IRQS ,
655+ .addr = (u64 )& uc_flic_b ,
656+ .attr = PAGE_SIZE ,
657+ },
658+ },
659+ {
660+ .name = "KVM_DEV_FLIC_ENQUEUE" ,
661+ .geterrno = EINVAL ,
662+ .a = { .group = KVM_DEV_FLIC_ENQUEUE , },
663+ },
664+ {
665+ .name = "KVM_DEV_FLIC_CLEAR_IRQS" ,
666+ .geterrno = EINVAL ,
667+ .a = { .group = KVM_DEV_FLIC_CLEAR_IRQS , },
668+ },
669+ {
670+ .name = "KVM_DEV_FLIC_ADAPTER_REGISTER" ,
671+ .geterrno = EINVAL ,
672+ .a = {
673+ .group = KVM_DEV_FLIC_ADAPTER_REGISTER ,
674+ .addr = (u64 )& uc_flic_ioa ,
675+ },
676+ },
677+ {
678+ .name = "KVM_DEV_FLIC_ADAPTER_MODIFY" ,
679+ .geterrno = EINVAL ,
680+ .seterrno = EINVAL ,
681+ .a = {
682+ .group = KVM_DEV_FLIC_ADAPTER_MODIFY ,
683+ .addr = (u64 )& uc_flic_ioam ,
684+ .attr = sizeof (uc_flic_ioam ),
685+ },
686+ },
687+ {
688+ .name = "KVM_DEV_FLIC_CLEAR_IO_IRQ" ,
689+ .geterrno = EINVAL ,
690+ .seterrno = EINVAL ,
691+ .a = {
692+ .group = KVM_DEV_FLIC_CLEAR_IO_IRQ ,
693+ .attr = 32 ,
694+ },
695+ },
696+ {
697+ .name = "KVM_DEV_FLIC_AISM" ,
698+ .geterrno = EINVAL ,
699+ .seterrno = ENOTSUP ,
700+ .a = {
701+ .group = KVM_DEV_FLIC_AISM ,
702+ .addr = (u64 )& uc_flic_asim ,
703+ },
704+ },
705+ {
706+ .name = "KVM_DEV_FLIC_AIRQ_INJECT" ,
707+ .geterrno = EINVAL ,
708+ .a = { .group = KVM_DEV_FLIC_AIRQ_INJECT , },
709+ },
710+ {
711+ .name = "KVM_DEV_FLIC_AISM_ALL" ,
712+ .geterrno = ENOTSUP ,
713+ .seterrno = ENOTSUP ,
714+ .a = {
715+ .group = KVM_DEV_FLIC_AISM_ALL ,
716+ .addr = (u64 )& uc_flic_asima ,
717+ .attr = sizeof (uc_flic_asima ),
718+ },
719+ },
720+ {
721+ .name = "KVM_DEV_FLIC_APF_ENABLE" ,
722+ .geterrno = EINVAL ,
723+ .seterrno = EINVAL ,
724+ .a = { .group = KVM_DEV_FLIC_APF_ENABLE , },
725+ },
726+ {
727+ .name = "KVM_DEV_FLIC_APF_DISABLE_WAIT" ,
728+ .geterrno = EINVAL ,
729+ .seterrno = EINVAL ,
730+ .a = { .group = KVM_DEV_FLIC_APF_DISABLE_WAIT , },
731+ },
732+ };
733+
734+ TEST_F (uc_kvm , uc_flic_attrs )
735+ {
736+ struct kvm_create_device cd = { .type = KVM_DEV_TYPE_FLIC };
737+ struct kvm_device_attr attr ;
738+ u64 value ;
739+ int rc , i ;
740+
741+ rc = ioctl (self -> vm_fd , KVM_CREATE_DEVICE , & cd );
742+ ASSERT_EQ (0 , rc ) TH_LOG ("create device failed with err %s (%i)" ,
743+ strerror (errno ), errno );
744+
745+ for (i = 0 ; i < ARRAY_SIZE (uc_flic_attr_tests ); i ++ ) {
746+ TH_LOG ("test %s" , uc_flic_attr_tests [i ].name );
747+ attr = (struct kvm_device_attr ) {
748+ .group = uc_flic_attr_tests [i ].a .group ,
749+ .attr = uc_flic_attr_tests [i ].a .attr ,
750+ .addr = uc_flic_attr_tests [i ].a .addr ,
751+ };
752+ if (attr .addr == 0 )
753+ attr .addr = (u64 )& value ;
754+
755+ rc = ioctl (cd .fd , KVM_HAS_DEVICE_ATTR , & attr );
756+ EXPECT_EQ (uc_flic_attr_tests [i ].hasrc , !!rc )
757+ TH_LOG ("expected dev attr missing %s" ,
758+ uc_flic_attr_tests [i ].name );
759+
760+ rc = ioctl (cd .fd , KVM_GET_DEVICE_ATTR , & attr );
761+ EXPECT_EQ (!!uc_flic_attr_tests [i ].geterrno , !!rc )
762+ TH_LOG ("get dev attr rc not expected on %s %s (%i)" ,
763+ uc_flic_attr_tests [i ].name ,
764+ strerror (errno ), errno );
765+ if (uc_flic_attr_tests [i ].geterrno )
766+ EXPECT_EQ (uc_flic_attr_tests [i ].geterrno , errno )
767+ TH_LOG ("get dev attr errno not expected on %s %s (%i)" ,
768+ uc_flic_attr_tests [i ].name ,
769+ strerror (errno ), errno );
770+
771+ rc = ioctl (cd .fd , KVM_SET_DEVICE_ATTR , & attr );
772+ EXPECT_EQ (!!uc_flic_attr_tests [i ].seterrno , !!rc )
773+ TH_LOG ("set sev attr rc not expected on %s %s (%i)" ,
774+ uc_flic_attr_tests [i ].name ,
775+ strerror (errno ), errno );
776+ if (uc_flic_attr_tests [i ].seterrno )
777+ EXPECT_EQ (uc_flic_attr_tests [i ].seterrno , errno )
778+ TH_LOG ("set dev attr errno not expected on %s %s (%i)" ,
779+ uc_flic_attr_tests [i ].name ,
780+ strerror (errno ), errno );
781+ }
782+
783+ close (cd .fd );
784+ }
785+
638786TEST_HARNESS_MAIN
0 commit comments